XSD Schema import

Discussion in 'XML' started by Victor Engmark, Feb 2, 2004.

  1. I am making an XML Schema for emails, and would like to specify that any
    elements from the XHTML2 namespace are allowed in the body/contents and
    signature/footer parts of the message (and _only_ there). I guess I have
    to use some combination of the xsd:import and xsd:any elements, but I'm
    not sure of the syntax.

    What should I fill into the following structure and/or the top of the file?

    <?xml version="1.0"?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">

    <!-- Definition of header structure -->

    <!-- Contents structure -->
    <xsd:complexType name="contentsType" use="optional">
    <xsd: ...
    </xsd:complexType>

    <!-- Footer structure -->
    <xsd:complexType name="footerType" use="optional">
    <xsd:element name="signature">
    <xsd: ...
    </xsd:element>
    </xsd:complexType>

    </xsd:schema>

    --
    Victor Engmark
    Victor Engmark, Feb 2, 2004
    #1
    1. Advertising

  2. Victor Engmark <> writes:

    > I am making an XML Schema for emails, and would like to specify that
    > any elements from the XHTML2 namespace are allowed in the
    > body/contents and signature/footer parts of the message (and _only_
    > there). I guess I have to use some combination of the xsd:import and
    > xsd:any elements, but I'm not sure of the syntax.
    >
    > What should I fill into the following structure and/or the top of the file?
    >
    > <?xml version="1.0"?>
    > <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    >
    > <!-- Definition of header structure -->
    >
    > <!-- Contents structure -->
    > <xsd:complexType name="contentsType" use="optional">
    > <xsd: ...
    > </xsd:complexType>


    Perhaps what you want is

    <xsd:complexType name="contentsType">
    <xsd:sequence>
    <xsd:any
    namespace="http://www.w3.org/2002/06/xhtml2"
    processContents="strict"
    minOccurs="0"
    maxOccurs="unbounded">
    </xsd:any>
    </xsd:sequence>
    </xsd:complexType>

    <!-- Footer structure -->
    > <xsd:complexType name="footerType" use="optional">
    > <xsd:element name="signature">
    > <xsd: ...
    > </xsd:element>
    > </xsd:complexType>


    Here it's not clear to me what you intend. If you want
    any number of XHTML 2 elements, intermingled with occurrences
    of the 'signature' element, then this should work:

    <xsd:complexType name="footerType">
    <xsd:choice minOccurs="0" maxOccurs="unbounded">
    <xsd:element name="signature"></xsd:element>
    <xsd:any namespace="http://www.w3.org/2002/06/xhtml2"
    processContents="strict">
    </xsd:any>
    </xsd:choice>
    </xsd:complexType>

    As far as I can tell, wildcards which allow elements (or attributes)
    from a particular namespace can be included in a schema document even
    when there is no import of the relevant namespace; an import is
    required if you want to say "an XHTML 2 div, h1, or p is allowed here"
    but not (as far as I can see from a quick look at the spec) for a
    wildcard. Also, neither Xerces J nor XSV complains about a missing
    import. But if you are designing your vocabulary to be used in
    conjunction with XHTML, an import would probably be a good idea.

    -C. M. Sperberg-McQueen
    World Wide Web Consortium
    C. M. Sperberg-McQueen, Feb 2, 2004
    #2
    1. Advertising

  3. C. M. Sperberg-McQueen wrote:

    > Victor Engmark <> writes:


    > <!-- Footer structure -->
    >
    >> <xsd:complexType name="footerType" use="optional">
    >> <xsd:element name="signature">
    >> <xsd: ...
    >> </xsd:element>
    >> </xsd:complexType>

    >
    >
    > Here it's not clear to me what you intend. If you want
    > any number of XHTML 2 elements, intermingled with occurrences
    > of the 'signature' element, then this should work:
    >
    > <xsd:complexType name="footerType">
    > <xsd:choice minOccurs="0" maxOccurs="unbounded">
    > <xsd:element name="signature"></xsd:element>
    > <xsd:any namespace="http://www.w3.org/2002/06/xhtml2"
    > processContents="strict">
    > </xsd:any>
    > </xsd:choice>
    > </xsd:complexType>


    No, it is more that the <signature> element is the only one I have
    thought of so far as the contents of <footer>. My XML could therefore
    have been written thus:
    <xsd:complexType name="signatureType" use="optional">
    <xsd: ...
    </xsd:complexType>

    What I wanted to express was that there will maximum one <signature> in
    the <footer>, but it can contain any XHTML2 elements.

    --
    Victor Engmark
    Victor Engmark, Feb 3, 2004
    #3
    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. Bernd Oninger
    Replies:
    1
    Views:
    522
    Henry S. Thompson
    Jun 30, 2004
  2. stiank81
    Replies:
    4
    Views:
    15,377
    stiank81
    Jun 26, 2005
  3. Rushi
    Replies:
    1
    Views:
    545
  4. Wm. Scott Miller

    Import XSD schema into WSDL

    Wm. Scott Miller, Aug 10, 2005, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    272
    Raghu
    Sep 14, 2005
  5. Replies:
    5
    Views:
    997
    Brian McCauley
    Nov 29, 2006
Loading...

Share This Page