473,320 Members | 2,027 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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

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.


Jul 20 '05 #1
0 2190

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Razvan | last post by:
Hi ! Where can I find the definition of the most used DTD/Schema expressions ? Something like: <!-- exclusive or: AAA or BBB but not both -->
2
by: Stanimir Stamenkov | last post by:
Validating this document <http://stanio.info/test_inst.xml> against the specified schema <http://stanio.info/test_schema.xml> gives me no errors. I've wondered why the text content appearing...
12
by: Stefano | last post by:
Hi all, what is the correct use of the "default" attribute in XML Schema? For example: <xs:element name="myProperty" type="xs:string" default="myDefaultValue"/> What can I do with it? What...
1
by: Mike Strieder | last post by:
How can i get the text of the System.Type e.g. "base64Binary" from the .Net type "byte" I can not found any Function to give back this Schematype as string. thx for your help
0
by: Chuck Bowling | last post by:
I have an XML Schema that's similar to the abbreviated version below; my problem is that both the XML designer in VS 2002 and xsd.exe apparently ignore the heirarchy that the Schema defines. In the...
2
by: Frosty | last post by:
Howto make datagrid enforce rules of xml schema? Created xml schema in the designer. Constraints created there using the following <xs:simpleType name="zipcode"><xs:restriction...
1
by: Trond | last post by:
I have a need to, given a XML document with XML Schema defined, to get the type of each element in the XML file based on the XML Schema URI given. IE, the <title> element is of simple datatype...
2
by: Mark Doerbandt | last post by:
Hi, I need to validate a XML document where some of the element names are unnknown. <xs:any processContents="lax"/> or "skip" allows me to do so. But: I want to validate those elements -...
1
by: Nichino | last post by:
Hello, I'm trying to define my first Xml Schema and have a problem. The XML I'd like to define through the Schema is the following one. Can you help me please? I don't know how to insert the 3...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.