473,320 Members | 1,879 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.

xsd element vs literal text ... why the difference

<?xml version="1.0" ?>
- <xsd:schema targetNamespace="urn:faster:userlogin"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="urn:faster:userlogin">
<xsd:include schemaLocation="C:\Faster\App\Demo\DataTypes\login .xsd"
/>
<xsd:include schemaLocation="C:\Faster\App\Demo\DataTypes\passw ord.xsd"
/>
- <xsd:complexType name="userloginType">
- <xsd:all>
<xsd:element name="login" type="login" />
<xsd:element name="password" type="password" />
</xsd:all>
</xsd:complexType>
<xsd:element name="userlogin" type="userloginType" />
</xsd:schema>

The above schema was produced by the following stylesheet. Note the
default namespace is only defined once. Here is the stylesheet

<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="urn:~app~:dummy"
version="1.0">
<xsl:output method="xml" version="1.0" encoding="UTF-8"
indent="yes"/>

<xsl:template match="/">
<xsd:schema>
<xsl:attribute
name="targetNamespace">urn:~app~:dummy</xsl:attribute>
<xsl:apply-templates select="files/file" mode="include"/>
<xsd:complexType name="dummyType">
<xsd:all>
<xsl:apply-templates select="files/file" mode="complexType"/>
</xsd:all>
</xsd:complexType>
<xsd:element name="dummy" type="dummyType"/>
</xsd:schema>
</xsl:template>

<xsl:template match ="files/file" mode="include">
<xsd:include schemaLocation = "{.}"/>
</xsl:template>
<xsl:template match ="files/file" mode="complexType">
<xsd:element name = "{.}" type="{.}"/>
</xsl:template>
</xsl:stylesheet>

Now by changing the xsd:schema in the stylesheet to xsl:element
name="xsd:schema" I get an equivalent but different result with the
default namespace being defined multiple times.

So this

<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="urn:~app~:dummy"
version="1.0">
<xsl:output method="xml" version="1.0" encoding="UTF-8"
indent="yes"/>

<xsl:template match="/">
<xsl:element name="xsd:schema">
<xsl:attribute
name="targetNamespace">urn:~app~:dummy</xsl:attribute>
<xsl:apply-templates select="files/file" mode="include"/>
<xsd:complexType name="dummyType">
<xsd:all>
<xsl:apply-templates select="files/file" mode="complexType"/>
</xsd:all>
</xsd:complexType>
<xsd:element name="dummy" type="dummyType"/>
</xsl:element>
</xsl:template>

<xsl:template match ="files/file" mode="include">
<xsd:include schemaLocation = "{.}"/>
</xsl:template>
<xsl:template match ="files/file" mode="complexType">
<xsd:element name = "{.}" type="{.}"/>
</xsl:template>
</xsl:stylesheet>

produces this schema
<?xml version="1.0"?>
<xsd:schema targetNamespace="urn:faster:userlogin"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:include schemaLocation="C:\Faster\App\Demo\DataTypes\login .xsd"
xmlns="urn:faster:userlogin" />
<xsd:include schemaLocation="C:\Faster\App\Demo\DataTypes\passw ord.xsd"
xmlns="urn:faster:userlogin" />
<xsd:complexType name="userloginType" xmlns="urn:faster:userlogin">
<xsd:all>
<xsd:element name='login' type='login' />
<xsd:element name='password' type='password' />
</xsd:all>
</xsd:complexType>
<xsd:element name="userlogin" type="userloginType"
xmlns="urn:faster:userlogin" />
</xsd:schema>

which has urn:faster:userlogin namespace defined 4 times.

Although they are equivalent why the difference...

PS the ~app~ in the stylesheets get replaced by a script before the
schema is produced.
Jul 20 '05 #1
0 3214

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

Similar topics

9
by: Steven T. Hatton | last post by:
This is from the draft of the previous version of the Standard: http://www.kuzbass.ru:8086/docs/isocpp/expr.html 2- A literal is a primary expression. Its type depends on its form...
2
by: RobG | last post by:
I am trying to dynamically add an onclick to an element, however I just can't get the syntax right. consider the following function: function doClick (evt,x) { // do things with evt and x } ...
2
by: pintihar | last post by:
I am trying to map external xml documents to a class in dotnet. The problem is that the elements of the input xml will have different names than the properties of the class. How do I create the...
6
by: Joe | last post by:
I know that the Literal control will not render a <span> tag so I can not format its text. Other than this, what is the difference betwen the Literal control and the LiteralControl Control? How...
5
by: George Jordanov Ivanov | last post by:
All, Today I was playing with Literal control. Basically it is more or less like the Label control with this difference that Literal control is something like "lightweight" text container (that...
0
by: sandycormie | last post by:
Hello I suspect the answer is going to be no, but... I have a class that contains a property defined as an abstract class. I would like to control the format of the generated XML to include a...
0
by: sandycormie | last post by:
Hello I suspect the answer is going to be no, but... I have a class that contains a property defined as an abstract class. I would like to control the format of the generated XML to include a...
12
by: Eric Layman | last post by:
Hi, What's the difference between a normal web element: <input type="text" id="txtname" name="txtname" runat="server"> vs webcontrol text box: <asp:Textbox id="username" Columns="10"...
5
by: cameljs18 | last post by:
Converting a string variable into a string literal. How do I add the @ character in front of the string? I cannot add it when the string is created as it will affect other parts of the program. ...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.