
Hi Timothy,
The sample covers both cases, the schema allows also the xi:include element (in the case when XInclude processing is disabled and this is needed also for content completion) and the content that replaces the xi:include (the additional xml:base attribute that appears on the included elements).
Thanks for the info. I'm not sure what that second part means; "and the content that replaces the xi:include". Would you explain this a little more?
When some element is included than an xml:base attribute appears on that element pointing to the file it was included from. In the second part I meant that the sample schema defines the xml:base attribute. You can see that very easily if you run the document through an identity XSLT transformation, for instance: test.xsl <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="/"> <xsl:copy-of select="."/> </xsl:template> </xsl:stylesheet> applied on test.xml <?xml version="1.0" encoding="UTF-8"?> <scopes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="test.xsd"> <scope name="test"/> <include xmlns="http://www.w3.org/2001/XInclude" href="included.xml"/> <scope name="another scope"/> </scopes> included.xml <?xml version="1.0" encoding="UTF-8"?> <scope name="inlcudedScope"> This is an <important>included</important> scope. </scope> gives (note the xml:base attribute on the included scope element) <?xml version="1.0" encoding="UTF-8"?><scopes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="test.xsd"> <scope name="test"/> <scope name="inlcudedScope" xml:base="file:/C:/Documents%20and%20Settings/Administrator.SPEECH/Desktop/xincludeWithSchema/included.xml"> This is an <important>included</important> scope. </scope> <scope name="another scope"/> </scopes>
Also, I have XInclude processing turned on. However, the main document still validates even with an error in the included document. Is this expected behavior? Would I have to do something like use XSLT to actually replace the included document in to the main document to do a single full validation?
Hmmm... If I edit the included.xml file and rename important as important2 then I get the following error: SystemID: [...]\included.xml Location: 5:15 Description: cvc-complex-type.2.4.a: Invalid content was found starting with element 'important2'. One of '{important}' is expected. URL: http://www.w3.org/TR/xmlschema-1/#cvc-complex-type No, you should not need to do anything than enabling the XInclude processing to perform a validation of the document that results after XIncludes are processed against an XML Schema. Note that the validation againt DTDs is different, in that case each document is validated against its DTD without expanding the XInclude elements. Best Regards, George --------------------------------------------------------------------- George Cristian Bina <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger http://www.oxygenxml.com