<?xml version="1.0" encoding="UTF-8"?>
<faq xmlns:xsi="http://www.w3.org/2000/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.schemavalid.com/faq/qaml-xml.xsd">
	<head>
		<title>XML Schema FAQ</title>
		<maintain>
			<name>Francis Norton</name>
			<email>fnorton@ie.com</email>
		</maintain>
		<hdr>
			<type/>
			<content>W3C XML Schema FAQ</content>
		</hdr>
	</head>
	<body>
		<section id="a">
			<title>Context and Purpose</title>
			<qna id="a1">
				<q>What, Why?</q>
				<a gist="XML Schema offers data-type features not provided by DTDs">
					<p>DTDs have several limitations, one of which is the fact that they are not written in standard XML data syntax. This means, for instance, that while it is quite possible to write an XSLT transform to document an XML Schema, there are far fewer tools to process DTDs</p>
					<p>XML Schema also offers several features which are urgently required for data processing applications, such as a sophisticated set of basic data types including dates, numbers and strings with facets that can be superimposed - inlcuding regular expressions and minimum and maximum ranges and lengths</p>
					<p>I am therefore maintaining this FAQ at the <link href="http://www.schemaValid.com">XML Schema FAQ</link> web site.</p>
				</a>
			</qna>
			<qna id="a2">
				<q>Who Cares?</q>
				<a gist="It will be particularly useful for people integrating diverse business systems">
					<p>Anyone who has to make different systems talk to each other. I've spent years doing client-server and web application development, and I know how much time is spent on attempting to specify and debug data buffers.</p>
					<p> XML Schema as the specification language and XML as the data language fill a gap as vast and as easily overlooked as the air we breathe.</p>
				</a>
			</qna>
			<qna id="a3">
				<q>Will XML Schema replace DTDs?</q>
				<a gist="No.">
					<p>It's an obvious question, but the answer appears to be no. [mailing list references to follow]</p>
				</a>
			</qna>
			<qna id="a6">
				<q>Can I combine XML Schema and DTDs?</q>
				<a gist="Yes.">
					<p>[Henry Thompson] DTD processing and XML Schema processing are completely independent, hence combinable:  just make sure your schema processor includes a validating XML parser as its first stage.</p>
				</a>
			</qna>
			<qna id="a7">
				<q>Which would take precedence, XML Schema or a DTD?</q>
				<a gist="The DTD.">
					<p>[Jeff Rafter] The DTD takes precedence for validation purposes. Schema validation comes after DTD validation (if any).  This is done to allow entities to be resolved before schema validation.  Of course some of this may be application specific..</p>
				</a>
			</qna>
			<qna id="a4">
				<q>Is XML Schema competing with Microsoft's XDR?</q>
				<a gist="No, XDR is meant to be a subset of the final XML Schema">
					<p>In a word, No. <link href="http://msdn.microsoft.com/library/psdk/xmlsdk/xmlp7k6d.htm">XML Data Reduced (XDR)</link> is meant to be a subset of the final XML Schema feature set, so that upward compatibility is not a problem. See the <link href="http://www.netcrucible.com/xslt/msxml-faq.htm#Q13">answer</link> on the very useful <link href="http://www.netcrucible.com/xslt/msxml-faq.htm">Unofficial MSXML FAQ</link>
					</p>
				</a>
			</qna>
			<qna id="a5">
				<q>What other supported validation technologies exist?</q>
				<a gist="Relax, Trex and Schematron">
					<p>
						<link href="http://www.xml.gr.jp/relax/">Relax</link> is positioned as being radically simpler and upwardly compatible</p>
					<p>James Clark, lead author of the XSLT and XPath specs, is developing <link href="http://www.thaiopensource.com/trex/">TREX</link>.</p>
					<p>
						<link href="http://www.ascc.net/xml/resource/schematron/schematron.html">Schematron</link> is XPath based, requires only XSLT to run, and aims to be complementary to XML Schema.
					</p>
					<p>
						See this best practice summary on <link href="http://www.xfront.com/ExtendingSchemas.html">extending XML Schemas</link> for an excellent discussion of the options and issues.
					</p>
				</a>
			</qna>
			<qna id="a8">
				<q>Could XML Schema be used to help compress XML Messages?</q>
				<a gist="In principle yes - see ASN.1">
					<p>
						Apart from the trivial sense of supplying the values of fixed attributes, there is a proposal to map XML Schemas to 
						<link href="http://asn1.elibel.tm.fr/xml/">ASN.1</link> - this covers mappings of both schemas and instances, and would 
						permit the use of existing ASN.1 technologies for signing and compressing messages.
					</p>
				</a>
			</qna>
		</section>
		<section id="b">
			<title>Resources</title>
			<qna id="b1">
				<q>Where are some good resources pages?</q>
				<a gist="W3C and Robin Cover's sites">
					<p>see  the <link href="http://www.w3.org/XML/Schema">W3C XML Schema page</link>, and Robin Cover's <link href="http://xml.coverpages.org/schemas.html">schema page</link>
					</p>
					<p>The FAQs for <link href="http://www.ucc.ie/xml/">XML</link> and <link href="http://www.dpawson.co.uk/xsl/xslfaq.html">XSL</link> may also be helpful.
					</p>
				</a>
			</qna>
			<qna id="b2">
				<q>Where can I find the spec?</q>
				<a gist="W3C">
					<p>
						see the W3C spec at <link href="http://www.w3.org/XML/Schema#dev">http://www.w3.org/XML/Schema#dev</link>, 
						and the W3C Working Draft on <link href="http://www.w3.org/TR/2001/WD-xmlschema-formal-20010320/">formalisation</link>.
					</p>
				</a>
			</qna>
			<qna id="b3">
				<q>Where can I find tutorials and design guidance?</q>
				<a gist="see the W3C Primer and Roger Costello's xfront tutorial">
					<p>"Part 0" of the spec is a <link href="http://www.w3.org/TR/xmlschema-0/">Primer</link>.</p>
					<p>There's an excellent tutorial at <link href="http://www.xfront.com/xml-schema.html">http://www.xfront.com/xml-schema.html</link>, though you'll need powerpoint to run it.</p>
					<p>www.xfront.com also hosts a <link href="http://www.xfront.com/BestPractices.html">best practice guide</link> looking at various design issues.</p>
				</a>
			</qna>
			<qna id="b4">
				<q>Where can I find tools and test cases?</q>
				<a gist="various links">
					<p>You can get an schema aware editor/validator from <link href="http://www.xmlspy.com/">XML Spy</link>, for Windows only.</p>
					<p>
						<link href="http://www.extensibility.com/tibco/solutions/index.htm">Tibco</link>'s  XML Instance editor/validator product also now supports XML Schema CR.  All of their client tools support Windows, Unix, and Mac (OS X). Their XML Authority also handles conversion between schema flavors, including XSD, DTD, XDR, and SOX.</p>
					<p>Validation can be done using Oracle's <link href="http://technet.oracle.com/tech/xml/schema_java/listing.htm">Java</link> and <link href="http://technet.oracle.com/tech/xml/schema_c/htdocs/readme.html">C</link> products.</p>
					<p>Apache - with IBM - has an open source validation project <link href="http://xml.apache.org/xerces-j/schema.html">Xerces</link>.</p>
					<p>Henry S. Thompson (lead author of the XML Schema specification) has a web-based and downloadable structure validator,  <link href="http://www.w3.org/2000/09/webdata/xsv">XSV</link>.</p>
					<p>Microsoft have announced support for the Proposed Recommendation (30th March) in a free technology preview of <link href="http://msdn.microsoft.com/downloads/default.asp?URL=/code/sample.asp?url=/MSDN-FILES/027/001/594/msdncompositedoc.xml">MSXML4</link>.</p>
					<p>
						<link href="http://jaxme.sourceforge.net/">JaxMe</link> is a source code generator that takes an XML Schema document as input and
          generates Java sources for working with compliant instances, including a SAX 2
          ContentHandler. Other generators include access to various persistence layers like
          RDBMS, Tamino or EJB entity beans. JaxMe supports the upcoming <link href="http://java.sun.com/xml/jaxb">JAXBE</link>.</p>
					<p>There is a collection of test cases at the <link href="http://www.w3.org/2001/05/xmlschema-test-collection.html">W3C XML Schema Test Collection</link>.</p>
				</a>
			</qna>
			<qna id="b5">
				<q>Newsgroups and Mailing lists?</q>
				<a gist="xmlschema-dev and xml-dev">
					<p>There is a dedicated mailing list at <link href="http://lists.w3.org/Archives/Public/xmlschema-dev/2000Apr/0001.html">xmlschema-dev</link>.</p>
					<p>If you are developing, rather than simply using, XML tools there is <link href="http://www.xml.org/xml-dev/index.shtml">xml-dev</link>.</p>
				</a>
			</qna>
		</section>
		<section id="c">
			<title>Development - Writing Schemas</title>
			<qna id="c1">
				<q>How can I convert DTDs and XDRs to XML Schema?</q>
				<a gist="various tool links">
					<p>There's an open-source tool for DTD conversion at: <link href="http://www.w3.org/2000/04/schema_hack/">DTD2Schema</link>.</p>
					<p>See <link href="http://www.xmlspy.com/">XML Spy</link>, for Windows, and <link href="http://www.extensibility.com/tibco/solutions/index.htm">Tibco</link>'s  XML Authority</p>
					<p>Microsoft have a beta <link href="http://msdn.microsoft.com/downloads/default.asp?URL=/code/sample.asp?url=/msdn-files/027/001/539/msdncompositedoc.xml">XDR Converter</link>.</p>
				</a>
			</qna>
			<qna id="c2">
				<q>How can I specify that a typed element may be empty rather than just nullable?</q>
				<a gist="use an xsd:union">
					<p>Henry Thompson posted the following answer to this problem, using the xsd:union feature</p>
					<p class="pre"><![CDATA[
<xsd:simpleType name="UprnType">
	<xsd:union>
		<xsd:simpleType>
			<xsd:restriction base="xsd:positiveInteger">
				<xsd:minInclusive value="1"/>
				<xsd:maxInclusive value="99999"/>
			</xsd:restriction>
		</xsd:simpleType>
		<xsd:simpleType>
			<xsd:restriction base="xsd:token">
				<xsd:enumeration value=""/>
			</xsd:restriction>
		</xsd:simpleType>
	</xsd:union>
</xsd:simpleType>]]></p>
				</a>
			</qna>
			<qna id="c3">
				<q>Can I have validation rules that depend on arbitrary logical conditions?</q>
				<a gist="you can't, for now.">
					<p>
						XML Schema provides powerful dedicated validation features for things like 
						<link href="http://www.w3.org/TR/xmlschema-0/#specifyingUniqueness">uniqueness</link>, 
						<link href="http://www.w3.org/TR/xmlschema-0/#specifying Keys&amp;theirRefs">referential integrity</link>, 
						<link href="http://www.w3.org/TR/xmlschema-0/#ref10">enumerations</link>, 
						<link href="http://www.w3.org/TR/xmlschema-0/#ref2">complex types</link> and the various 
						<link href="http://www.w3.org/TR/xmlschema-0/#SimpleTypeFacets">datatype facets</link>, 
						but it doesn't support arbitrary validation logic.
					</p>
					<p>
						However, in answer to the question:
						"is it possible to define in a XML-Schema that a elements only appears if 
						a attribute of another elements has a special entry (e.g. one of two 
						enumeration-values)"
						Henry Thompson <link href="http://lists.w3.org/Archives/Public/xmlschema-dev/2001Feb/0109.html">replied</link>:
						"No, co-constraints like this will not be supported until v1.1"
					</p>
					<p>
						XML Schema also provides a kind of general expansion slot in the form of the annotation / 
						<link href="http://www.w3.org/TR/xmlschema-0/#ref15">appInfo</link> element, 
						which allows information for other processors to be associated with a component. This might be used for 
						<link href="http://www.ascc.net/xml/resource/schematron/schematron.html">Schematron</link> rules, for instance.
					</p>
				</a>
			</qna>
			<qna id="c4">
				<q>Can a complexType element contain other complexType elements?</q>
				<a gist="yes.">
					<p>Yes, see the <link href="http://www.w3.org/TR/xmlschema-0/#po.xsd">PO example</link> in the primer.</p>
					<p>[Noah Mendelsohn] The correct terminology would be that (1) a complex type can have a content model, 
					which can indicate sequences of elements, choices of elements, etc., just as for DTD element types (2) some of the elements 
					named in that content model can themselves be of one or another complex 
					type, or simple type (3) if any of those elements have local declarations, 
					then in the XML transfer syntax, the type declarations are lexically 
					nested, and in that sense can appear to be contained.</p>
					<p>llustration of points (1) and (2):</p>
					<p class="pre"><![CDATA[
<complexType name='ct'>
	<!-- here comes a content model -->
	<sequence>
		<!-- ...with elements that have types -->
		<element ref="A"/>
		<element ref="B"/>
	</sequence>
</complexType'>

<element name="A" type="CT2"/>
<element name="B" type="CT3"/>
]]></p>
					<p>...and point (3):</p>
					<p class="pre"><![CDATA[
<complexType name='ct'>
	<!-- here comes a content model -->
	<sequence>
		<!-- A has anonymous complex type: it looks like it's nested (but in the
		schema components, we just say  it's scoped) -->
		<element name="A">
			<complexType>
				<sequence>
					...
				</sequence>
			</complexType>
		</element>
		<element ref="B"/>
	</sequence>
</complexType>
]]></p>
				</a>
			</qna>
			<qna id="c5">
				<q>Can a schema define a namespace with local elements and attributes which are not associated with the target namespace?</q>
				<a gist="Yes.">
					<p>
					[Noah Mendelsohn] I think the answer is right there in the question.  With or without
					schemas, the vast majority of namespace-based vocabularies use unqualified
					attributes :
					</p>
					<p class="pre"><![CDATA[ 
<myns:e attr1="..."  xmlns:myns="someuri"/>
]]></p>
					<p>
					The namespaces <link href="http://www.w3.org/TR/REC-xml-names/#defaulting">recommendation</link> facilitiates such behavior by declining to
					apply namespace defaults to attributes:
					</p>
					<p class="pre"><![CDATA[ 
<!-- same element as above, attr still unqualified -->
<e attr1="..."   xmlns="someuri"/>
]]></p>
					<p>
					The default behavior of the schema specification is to extend that
					convention to locally scoped elements:
					</p>
					<p class="pre"><![CDATA[
<myns:outer attr="..." xmlns:myns="someuri">
	<inner/>
</myns:outer>
]]></p>
					<p>
					both attr and inner are conceptually associated with the qualified element
					myns:outer;  in other words, they are locally scoped.
					</p>
					<p>
					I can tell you that the schema workgroup devoted literally months of
					concentrated effort to the issues underlying the design for local element
					qualification that you find in our specification.  That does not
					necessarily mean that everyone in the workgroup is equally happy with our
					final decision, but it does indicate that there are many, many subtleties
					and that great care was taken in their consideration.
					</p>
				</a>
			</qna>
			<qna id="c6">
				<q>What is the "ur-definition"?</q>
				<a gist="an obscure term for the root supertype">
					<p>
						[Noah Mendelsohn] From the <link href="http://www.w3.org/TR/xmlschema-1/#key-urType">specification</link>:
					</p>
					<p>
						"[Definition:]  A distinguished ur-type definition is present in each XML 
						Schema, serving as the root of the type definition hierarchy for that 
						schema. The ur-type definition, whose name is anyType, has the unique 
						characteristic that it can function as a complex or a simple type 
						definition, according to context. Specifically, restrictions of the 
						ur-type definition can themselves be either simple or complex type 
						definitions."
					</p>
					<p>
						I think that says it, the ur-type is the root of the type hierarchy in 
						each schema.  It's like "object" in Java, everything derives from it.  
					</p>
					<p>
						[Martin Duerst explains the "ur-" prefix] "I happen to speak German, and [...] Ur- appears in
						things such as Ursprung (origin), Urgrossvater (great-grandfather),
						Urknall (big bang), Ursache (cause, reason), Urheber (originator,
						author), Urgewalt (elemental force), and so on. The general meaning 
						is something like 'original', 'very very old', and so on."
					</p>
					<p>
						So, ur-type is approximately supertype or 
						root type.  I personally would not have gone for such an obscure name, 
						but....  Anyway, the actual string name you use for it in a schema 
						document is "anyType".  e.g.
					</p>
					<p class="pre"><![CDATA[ 
<xs:element name="envelope"  type="xs:anyType"/>
]]></p>
					<p>
						The manifestation of the urType that admits only simple types is 
						anySimpleType:
					</p>
					<p class="pre"><![CDATA[ 
<xs:attribute name="thisAttrCanHoldAnyString" type="xs:anySimpleType"/>
]]></p>
					<p>
						The term urType shows up only when you read the specification itself 
						(historically we called it the urType, then added the convenience name, 
						and decided not to change the whole rest of the spec.  Users see "anyType" 
						and "anySimpleType".)  There are some subtleties in the type hierarchy, 
						but the above should get you through 99%+ of what you need to do.  Hope 
						this helps.
					</p>
					<p>
						[FN.] The original explanation of the "ur-" prefix triggered some email, but seems near enough - see, for example, this <link href="http://www.xrefer.com/entry/573646">definition</link>.
					</p>
				</a>
			</qna>
			<qna id="c-twoNamespaces">
				<q>Why are there two different namespaces for declaring types?</q>
				<a gist="one for declaring types inside schemas, one for inside instances">
					<p>
						The built-in datatypes defined by XML Schema part2 have namespace URI 
						(see 3.1 Namespace considerations in XML Schema part2):
					</p>
					<p class="pre">
http://www.w3.org/2000/10/XMLSchema-datatypes
					</p>
					<p>
						To declare an element which has a built-in datatype, which is correct?
					</p>
					<p class="pre"><![CDATA[
<xsd:schema xmlns:xsd="http://www.w3.org/2000/10/XMLSchema">
	<xsd:element name="comment" type="xsd:string"/>
]]></p>
					<p>
						or
					</p>
					<p class="pre"><![CDATA[
<xsd:schema xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"
	xmlns:xsdatatype="http://www.w3.org/2000/10/XMLSchema-datatypes">
	<xsd:element name="comment" type="xsdatatype:string"/>
]]></p>
					<p>
						The first.
					</p>
					<p>
						Because the built-in datatypes are intended to be used both by the schema language and by other 
						specifications, it was decided that there should be two namespaces.  
					</p>
					<p>
						The XML Schema namespace (http://www.w3.org/2000/10/XMLSchema) is to be used to identify 
						a built-in datatype whenever  that type is being used IN THE CONTEXT of an XML Schema; the XML 
						Schema Datatypes namespace (http://www.w3.org/2000/10/XMLSchema-datatypes) is to be used to 
						identify a schema datatype whenever that type is being used OUTSIDE THE CONTEXT of an XML Schema.					
					</p>
				</a>
			</qna>
		</section>
		<section id="d">
			<title>Development - Root Elements and Schema Links</title>
			<qna id="d1">
				<q>How do I link an Instance document to a Schema?</q>
				<a gist="use xsi:noNamespaceSchemaLocation or xsi:schemaLocation">
					<p>This is discussed in the Primer <link href="http://www.w3.org/TR/xmlschema-0/#NS">Section 3</link>.</p>
					<p>Basically there is no direct linkage feature of any kind. The instance document can suggest a link to the parser, but the application or parser may override the choice, for instance by using a different, preferred schema, or by using a cached copy of the suggested schema.</p>
					<p>if the instance document doesn't have a namespace, use xsi:noNamespaceSchemaLocation, for example:</p>
					<p class="pre"><![CDATA[
[s1.xsd]

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2000/10/XMLSchema" elementFormDefault="qualified">
	<xsd:element name="root">
		<xsd:complexType>
			<xsd:sequence>
				<xsd:element name="grade" type="abc"/>
			</xsd:sequence>
		</xsd:complexType>
	</xsd:element>
	<xsd:simpleType name="abc">
		<xsd:restriction base="xsd:string">
			<xsd:enumeration value="a"/>
			<xsd:enumeration value="b"/>
			<xsd:enumeration value="c"/>
		</xsd:restriction>
	</xsd:simpleType>
</xsd:schema>
]]></p>
					<p class="pre"><![CDATA[
[s1.xml]

<root xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance" xsi:noNamespaceSchemaLocation="s1.xsd" >
	<grade>a</grade>
</root>
]]></p>
					<p>if the instance document does have a namespace, use xsi:schemaLocation, for example:</p>
					<p class="pre"><![CDATA[
[s1ns.xsd]

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema 
		xmlns:s1="http://www.schemaValid.com/s1ns" 
		targetNamespace="http://www.schemaValid.com/s1ns" 
		xmlns:xsd="http://www.w3.org/2000/10/XMLSchema" 
		elementFormDefault="qualified" >
	<xsd:element name="root">
		<xsd:complexType>
			<xsd:sequence>
				<xsd:element name="grade" type="s1:abc"/>
			</xsd:sequence>
		</xsd:complexType>
	</xsd:element>
	<xsd:simpleType name="abc">
		<xsd:restriction base="xsd:string">
			<xsd:enumeration value="a"/>
			<xsd:enumeration value="b"/>
			<xsd:enumeration value="c"/>
		</xsd:restriction>
	</xsd:simpleType>
</xsd:schema>
]]></p>
					<p class="pre"><![CDATA[
[s1.xml]

<s1:root xmlns:s1="http://www.schemaValid.com/s1ns" 
			xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
 			xsi:schemaLocation="http://www.schemaValid.com/s1ns s1ns.xsd" >
	<s1:grade>a</s1:grade>
</s1:root>
]]></p>
				</a>
			</qna>
			<qna id="d2">
				<q>Why can't I specify an unconditional link from an Instance document to a Schema?</q>
				<a gist="because XML Schema gives the application the last word">
					<p>					[Noah Mendelsohn] Different applications require different conventions for determining the 
					schema to be used for validation.  For example, an author of individual 
					documents may prefer to indicate directly in the document the location of 
					the schema to be used.  Conversely, an e-commerce site might depend on a 
					particular vocabulary, and might not trust the user to determine the 
					schema, even if the user were prepared to do so.
					</p>
					<p>The schema design therefore avoids mandating a particular policy, but it 
					is anticipated that users will acquire and configure processors that do 
					enforce rules appropriate to their needs.  So, the schema specification 
					formally provides xsi:schemaLocation as a hint:  some processors may 
					follow it, others not.  The first user above would indeed do well to use a 
					processor that unconditionally follows schemaLocation, and in that sense 
					elevates it from a hint to a mandatory pointer.  The second user would do 
					well to use a processor that either (1) ignores schemaLocation or (2) 
					chooses to reject documents containing schemaLocations or (3) rejects 
					documents in which the schemaLocation does not match the intended schema 
					document.  Thus, by using the appropriate processor or processor mode, 
					users can indeed rely on behavior appropriate to particular needs.
					</p>
					<p>Note on options (2) and (3):  the schema specification calls for no such 
					checking or error indications, but nothing can prevent a particular 
					processor from declining to attempt a validation based on criteria that 
					meet the users needs (in this case, that the user is unhappy with the 
					schemaLocation occurrence or contents.)  If a validation is attempted 
					against one schema or another, the schema specification is very specific 
					about the required results.
					</p>
					<p>One final note:  certain schemas provide default values for attributes and 
					elements.  In cases where schemaLocation is not honored, users must be 
					very careful to ensure that any such defaults supplied by the schema 
					actually used for validation are consistent with those assumed by the 
					document author.  In typical eCommerce scenarios, the company offering the 
					service, or some organization in which they participate, will widely 
					publicize the schemas to be used and the implications of any defaults.  At 
					some point in the future, more robust means of protecting against 
					unintended schema uses may be provided.
					</p>
				</a>
			</qna>
			<qna id="d3">
				<q>How can a schema specify a mandatory root element?</q>
				<a gist="Only the message consumer can do this.">
					<p>There's no intended method for doing this, though you might be able to hack it by having only one globally declared element.</p>
					<p>
						The intention of the schema seems to be that of the three roles in any transaction 
						- the schema author, the message author, and the message reader - the message reader should have the last word in specifying to a 
						schema-validating parser what may be a root element. 
					</p>
				</a>
			</qna>
			<qna id="d6">
				<q>Can the message reader force a specific global element to be the message root?</q>
				<a gist="That's the intention of the spec.">
					<p>
						[Noah Mendelsohn] Yes. As far as the schema language itself is concerned any global element can be used as a root element, but it is 
						intended that the application or processor could be parameterized to 
						check.  For example, consider a perfectly reasonable processor that would 
						take a command line like:
					</p>
					<p class="pre"><![CDATA[
validate -instance myinstance.xml -schema myschema.xsd -rootElementName purchaseOrder
]]></p>
					<p>
						such a processor could provide the added service of checking the name of 
						the root element.  There are at least two reasons that the schema language 
						does not take a more rigid view of roots (a) there are situations in which 
						you truly find it useful to have different element names serve as the root 
						of  a document and (b) even if purchaseOrder is the root of the instance, 
						you may decide that you only want to validate the shippingAddress.   So, 
						the root of the validation need not be the root of the instance document.
					</p>
				</a>
			</qna>
			<qna id="d4">
				<q>Can schemas validate parts of an instance document?</q>
				<a gist="Basically, yes.">
					<p>Yes, for example <link href="http://www.w3.org/2000/09/webdata/xsv">XSV</link>, for example, will use "strict" mode if every element from the root down is schema-validatable, 
					but "lax" mode if the root node - or any other element which is allowed to appear in some context - cannot itself be schema-validated.
					</p>
					<p>[Noah Mendelsohn] From <link href="http://www.w3.org/TR/xmlschema-1/#validation_outcome">xmlschema-1</link>: "With a schema which satisfies the conditions expressed in Errors in 
					Schema Construction and Structure (§7.1) above, the schema-validity of an 
					element information item can be assessed.".  It then goes on to say 
					exactly how and against which declarations.  Note that it says you can 
					validate an "element", not necessarily the root element of a document.
					</p>
					<p>Net answer to your question:  conforming processors can be written to 
					validate any element you like.  Not all processors need provide this 
					service:  buy or use processors that validate the information you need 
					validated.  By the way, the detailed rules give the processor a choice of 
					validating the element against some particular identified element 
					declaration, some particular identified complex type, or to use the 
					mechanisms of strict, lax etc. to determine what to validate based on what 
					declarations happen to be available.  All of this is explained at <link href="http://www.w3.org/TR/xmlschema-1/#validation_outcome">xmlschema-1</link>.
					</p>
				</a>
			</qna>
			<qna id="d5">
				<q>Can I use global elements at any random point in my instance document?</q>
				<a gist="No, no - that's not what 'global' means.">
					<p>
					[Noah Mendelsohn] Declaring a global element does NOT directly allow that element to appear 
					in arbitrary points in the validated XML instance document.  Global elements are available 
					for reference when building content models.  Only the global elements you 
					actually reference from a content model (or allow through use of 
					wildcards) can appear in valid content.
					</p>
					<p class="pre"><![CDATA[
<xsd:element name="a" .... />
<xsd:element name="b" .... />
<xsd:element name="c" .... />

<xsd:element name="x">
	<xsd:complexType> 
		<xsd:sequence>
			<xsd:element ref="b"/>
			<xsd:element ref="c"/>
		</xsd:sequence>
	</xsd:complexType> 
</xsd:element>
]]></p>
					<p>
					The global elements named "b" and "c" must occur as children of "x" in the 
					instance document; global element "a" is not legal within "x".  Depending 
					how the processor is invoked, any of "a", "b", "c" or "x" might be usable 
					as the root of the validation (which might mean as the root of the whole 
					document, or it might mean that you are validating only part of the 
					document.)
					</p>
					<p>
					I think the confusion probably arises because readers see the term 
					"global" and presume it to mean "anywhere in the instance document".  In 
					fact, it means "available for use in any content model in the schema".  By 
					contrast, "local" elements can only be used in the content model of the 
					corresponding (scoping) complex type. Another way to think about this is 
					that global element declarations in schemas give you the same capabilities 
					as the element type declarations in XML 1.0 DTDs.  Local declarations are 
					an enhancement in schemas, allowing  the same name to be used for 
					different purposes according to context.  If you were doing a straight 
					conversion from a DTD to a schema, most likely all the resulting element 
					declarations would be global. 
					</p>
				</a>
			</qna>
		</section>
		<section id="e">
			<title>Development - Multi-Document Schemas</title>
			<qna id="e1">
				<q>How can I break a schema into separate modules?</q>
				<a gist="use xsd:include">
					<p>In XML Schema, the <![CDATA[<include>]]> element provides for schema modularity. See the XML Schema Primer [1] for more introductory information.</p>
					<p>[1] <link href="http://www.w3.org/TR/xmlschema-0/#SchemaInMultDocs">http://www.w3.org/TR/xmlschema-0/#SchemaInMultDocs</link>
					</p>
				</a>
			</qna>
			<qna id="e2">
				<q>How can I vary just one type definition in a schema document?</q>
				<a gist="use xsd:redefine">
					<p>
						In XML Schema, the <![CDATA[<xsd:redefine>]]> element provides for schema modularity with variation,
						see <link href="http://www.w3.org/TR/xmlschema-1/#modify-schema">http://www.w3.org/TR/xmlschema-1/#modify-schema</link>
					</p>
					<p>
						For a minimal example which works with XSV, assume that [s1.xsd]:
					</p>
					<p class="pre"><![CDATA[
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2000/10/XMLSchema" elementFormDefault="qualified">
	<xsd:element name="root">
		<xsd:complexType>
			<xsd:sequence>
				<xsd:element name="grade" type="abc"/>
			</xsd:sequence>
		</xsd:complexType>
	</xsd:element>
	<xsd:simpleType name="abc">
		<xsd:restriction base="xsd:string">
			<xsd:enumeration value="a"/>
			<xsd:enumeration value="b"/>
			<xsd:enumeration value="c"/>
		</xsd:restriction>
	</xsd:simpleType>
</xsd:schema>
]]></p>
					<p>
						defines messages like [s1.xml]:
					</p>
					<p class="pre"><![CDATA[
<root xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance" xsi:noNamespaceSchemaLocation="s1.xsd" >
	<grade>c</grade>
</root>
]]></p>
					<p>
						Now [s1_redefine.xsd]:
					</p>
					<p class="pre"><![CDATA[
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2000/10/XMLSchema" elementFormDefault="qualified">
	<xsd:redefine schemaLocation="s1.xsd">
		<xsd:simpleType name="abc">
			<xsd:restriction base="abc">
				<xsd:enumeration value="a"/>
			</xsd:restriction>
		</xsd:simpleType>
	</xsd:redefine>
</xsd:schema>
]]></p>
					<p>
						will only permit files like [s1_redefine.xml]:
					</p>
					<p class="pre"><![CDATA[
<root xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance" xsi:noNamespaceSchemaLocation="s1_redefine.xsd">
	<grade>a</grade>
</root>
]]></p>
					<p>
						note that the redefined type definition for the grade element of type abc applies even though it is called from a context - the root element -
						which is only defined in the original [s1.xsd]. 
					</p>
				</a>
			</qna>
		</section>
	</body>
</faq>
