XSD Schema import

V

Victor Engmark

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>
 
C

C. M. Sperberg-McQueen

Victor Engmark said:
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>

<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
 
V

Victor Engmark

C. M. Sperberg-McQueen said:
Victor Engmark <[email protected]> writes:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,233
Members
46,821
Latest member
AleidaSchi

Latest Threads

Top