Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > XSL rules applying to XSD (XML schema) defined type names (as opposed to node names)

Reply
Thread Tools

XSL rules applying to XSD (XML schema) defined type names (as opposed to node names)

 
 
Lewis G. Pringle, Jr.
Guest
Posts: n/a
 
      09-30-2003
Folks:
I have some XML text I'm tranforming from one schema to another. Both
schemas have their own notion of 'address' (as well as many other contepts).

XSL seems to be mainly suited to transforming XML types based on their
name. For example:

<xsl:template match="user-address">
<xsl:element name="Addr">
<xsl:element name="Addr1"><xsl:value-of select="line-1"/></xsl:element>
<xsl:element name="City"><xsl:value-of select="city"/></xsl:element>
<xsl:element name="StateProvCd"><xsl:value-of
select="state-abbreviation"/></xsl:element>
<xsl:element name="PostalCode"><xsl:value-of select="zip"/></xsl:element>
</xsl:element>
</xsl:template>

This seems to do an admirable job of transforming all instances of
'user-address' in my source XML file into the appropriate contruct in the
destination XML file.

But - my schemas are very complicated, and - for example - have many
addresses. They also have a 'company-address'. The structure of the mapping
is IDENTICAL.

Helpfully - these XML files are already constructed with XML schemas.
And - both schemas have a 'complex-type' declared for these addresses (as in
<xs:complexType name="address-type"><xs:sequence> <xs:element name="line-1"
type="xs:string"/>..... AND <xs:element name="user-address"
type="address-type"/>). So - I hoped to leverage this in my xsl:template.
I've tried LOTS of variations on this - but none seem to work:

<xsl:template match="self[@type='address-type']">
<xsl:element name="Addr">
<xsl:element name="Addr1"><xsl:value-of select="line-1"/></xsl:element>
<xsl:element name="City"><xsl:value-of select="city"/></xsl:element>
<xsl:element name="StateProvCd"><xsl:value-of
select="state-abbreviation"/></xsl:element>
<xsl:element name="PostalCode"><xsl:value-of select="zip"/></xsl:element>
</xsl:element>
</xsl:template>

Unfortunately - this rule never seems to get matched. So - I tried

<xsl:template match="user-address">
<xsl:element name="Addr">
<xsl:element name="SHOW_TYPE"><xsl:value-of
select="@type"/></xsl:element>
</xsl:element>
</xsl:template>

And I was surprised to see no type is output (e.g. <SHOW_TYPE />).

Any clues what maybe going on? Is this a supported thing to do with
XSL? (btw - I've treid using MSXML 4.0 and XERCES - don't remmeber the
version# - but it was recent).

Please reply by email.

Lewis.






 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
I want to select all the node names beneath a given node thecolour XML 2 06-27-2007 10:46 AM
I want to select all the node names beneath a given node thecolour XML 0 06-26-2007 04:01 PM
xsl variable $node/text() but $node can non-node-set help! Tjerk Wolterink XML 2 08-24-2006 03:28 AM
How to set the node indent property between the parent node and the leaf node viveknatani@gmail.com ASP .Net 0 02-13-2006 07:11 PM
'NODE' is used as a type, but has not been defined as a type Kabeer C++ 6 08-21-2003 03:54 PM



Advertisments