Victor Engmark <vi************@cern.ch> 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