xsd element vs literal text ... why the difference

Discussion in 'XML' started by wooks, Jul 31, 2003.

  1. wooks

    wooks Guest

    <?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">
    <xsl:eek:utput 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:eek:utput 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.
    wooks, Jul 31, 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. Matthet
    Replies:
    2
    Views:
    669
    Matthet
    Sep 24, 2003
  2. Bernd Oninger
    Replies:
    1
    Views:
    524
    Henry S. Thompson
    Jun 30, 2004
  3. Mr. SweatyFinger
    Replies:
    2
    Views:
    1,840
    Smokey Grindel
    Dec 2, 2006
  4. HANM
    Replies:
    2
    Views:
    709
    Joseph Kesselman
    Jan 29, 2008
  5. Anonieko Ramos

    What's wrong with rpc-literal? Why use doc-literal?

    Anonieko Ramos, Sep 27, 2004, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    374
    Anonieko Ramos
    Sep 27, 2004
Loading...

Share This Page