W
wooks
<?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\password.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">
<xslutput 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">
<xslutput 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\password.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.
- <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\password.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">
<xslutput 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">
<xslutput 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\password.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.