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

Discussion in 'XML' started by Lewis G. Pringle, Jr., Sep 30, 2003.

  1. 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.
     
    Lewis G. Pringle, Jr., Sep 30, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Markus
    Replies:
    1
    Views:
    1,665
    Markus
    Nov 23, 2005
  2. stiank81
    Replies:
    4
    Views:
    15,516
    stiank81
    Jun 26, 2005
  3. Rushi
    Replies:
    1
    Views:
    582
  4. Tjerk Wolterink
    Replies:
    2
    Views:
    1,508
    Dimitre Novatchev
    Aug 24, 2006
  5. Replies:
    5
    Views:
    1,110
    Brian McCauley
    Nov 29, 2006
Loading...

Share This Page