
I have an xml schema I've created. I'd like to have several XML documents that are combined into a larger one (I do this with DocBook & chapters). But I can't figure out how to do this with XMLSchema. Basically what I have is one xml document per environment (it's for configuration information). I'd like to have a parent document that has elements from the schema that are generic to the overall base, then includes the several smaller environment xml documents. Any ideas? Thanks!

On Tue, July 17, 2007 10:19, Timothy Reaves wrote:
I have an xml schema I've created. I'd like to have several XML documents that are combined into a larger one (I do this with DocBook & chapters). But I can't figure out how to do this with XMLSchema.
Basically what I have is one xml document per environment (it's for configuration information). I'd like to have a parent document that has elements from the schema that are generic to the overall base, then includes the several smaller environment xml documents. Any ideas?
Thanks!
I believe I have this with <xs:import namespace="http://www.w3.org/2003/XInclude" schemaLocation="xinclude.xsd"/> in my xsd file, and then I have an element <xs:element name="scopes"> <xs:complexType> <xs:sequence> <xs:element ref="xi:include" minOccurs="0"/> </xs:sequence> </xs:complexType> </xs:element> but oXygen fails to validate this line <xs:element ref="xi:include" minOccurs="0"/> with the error SystemID: D:\dev\workspace\JDISoarianInstallerJava\src\resources\deployment.xsd Location: 70:24 Description: src-resolve.4.2: Error resolving component 'xi:include'. It was detected that 'xi:include' is in namespace 'http://www.w3.org/2001/XInclude', but components from this namespace are not referenceable from schema document 'file:/D:/dev/workspace/JDISoarianInstallerJava/src/resources/deployment.xsd'. If this is the incorrect namespace, perhaps the prefix of 'xi:include' needs to be changed. If this is the correct namespace, then an appropriate 'import' tag should be added to 'file:/D:/dev/workspace/JDISoarianInstallerJava/src/resources/deployment.xsd'. URL: http://www.w3.org/TR/xmlschema-1/#src-resolve

Dear Timothy, oXygen has an option "Enable XInclude processing" that I believe is enabled by default. When that is enables the validation against XML Schema is performed after XInclude processing, that means the XML Schema should not care about defining the xi:include element but it should take into account that the included fragment will have an xml:base attribute pointing to the location it was included from and probably also an xml:lang. So for instance if you want to have scope elements inside scopes and you plan to include scope elements from other documents using XInclude then you should define xml:base (and xml:lang) to be allowed in the scope element. When the XInclude processing is not enabled then oXygen will validate the document as it is against the specified XML Schema. In that case you need to refer to the xi:include element inside the schema, as in your sample. The problem in your case is the wrong namespace that you used in import, the correct nemespace is http://www.w3.org/2001/XInclude, that is not with 2003. Best Regards, George --------------------------------------------------------------------- George Cristian Bina <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger http://www.oxygenxml.com Timothy Reaves wrote:
On Tue, July 17, 2007 10:19, Timothy Reaves wrote:
I have an xml schema I've created. I'd like to have several XML documents that are combined into a larger one (I do this with DocBook & chapters). But I can't figure out how to do this with XMLSchema.
Basically what I have is one xml document per environment (it's for configuration information). I'd like to have a parent document that has elements from the schema that are generic to the overall base, then includes the several smaller environment xml documents. Any ideas?
Thanks!
I believe I have this with
<xs:import namespace="http://www.w3.org/2003/XInclude" schemaLocation="xinclude.xsd"/>
in my xsd file, and then I have an element
<xs:element name="scopes"> <xs:complexType> <xs:sequence> <xs:element ref="xi:include" minOccurs="0"/> </xs:sequence> </xs:complexType> </xs:element>
but oXygen fails to validate this line
<xs:element ref="xi:include" minOccurs="0"/>
with the error
SystemID: D:\dev\workspace\JDISoarianInstallerJava\src\resources\deployment.xsd Location: 70:24 Description: src-resolve.4.2: Error resolving component 'xi:include'. It was detected that 'xi:include' is in namespace 'http://www.w3.org/2001/XInclude', but components from this namespace are not referenceable from schema document 'file:/D:/dev/workspace/JDISoarianInstallerJava/src/resources/deployment.xsd'. If this is the incorrect namespace, perhaps the prefix of 'xi:include' needs to be changed. If this is the correct namespace, then an appropriate 'import' tag should be added to 'file:/D:/dev/workspace/JDISoarianInstallerJava/src/resources/deployment.xsd'. URL: http://www.w3.org/TR/xmlschema-1/#src-resolve
_______________________________________________ oXygen-user mailing list oXygen-user@oxygenxml.com http://www.oxygenxml.com/mailman/listinfo/oxygen-user

On Tue, July 17, 2007 16:13, George Cristian Bina wrote:
Dear Timothy,
oXygen has an option "Enable XInclude processing" that I believe is enabled by default. When that is enables the validation against XML Schema is performed after XInclude processing, that means the XML Schema should not care about defining the xi:include element but it should take into account that the included fragment will have an xml:base attribute pointing to the location it was included from and probably also an xml:lang. So for instance if you want to have scope elements inside scopes and you plan to include scope elements from other documents using XInclude then you should define xml:base (and xml:lang) to be allowed in the scope element.
When the XInclude processing is not enabled then oXygen will validate the document as it is against the specified XML Schema. In that case you need to refer to the xi:include element inside the schema, as in your sample. The problem in your case is the wrong namespace that you used in import, the correct nemespace is http://www.w3.org/2001/XInclude, that is not with 2003.
Best Regards, George
Do you have a sample document that shows this working correctly?

Dear Timothy, Ok, I created a full working sample starting from your schema fragment. Basically we define a "scopes" element that can contain more "scope" elements. A "scope" element has mixed content and can contain "important" elements. All the sample files are available also in an archive here http://www.oxygenxml.com/update/xincludeWithSchema.zip 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). test.xsd: <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xi="http://www.w3.org/2001/XInclude"> <xs:import namespace="http://www.w3.org/2001/XInclude" schemaLocation="xinclude.xsd"/> <xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="xml.xsd"/> <xs:element name="scopes"> <xs:complexType> <xs:sequence maxOccurs="unbounded"> <xs:choice> <xs:element ref="xi:include" minOccurs="0"/> <xs:element ref="scope"/> </xs:choice> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="scope"> <xs:complexType> <xs:complexContent> <xs:extension base="scopeType"> <xs:attributeGroup ref="xml:specialAttrs"/> </xs:extension> </xs:complexContent> </xs:complexType> </xs:element> <xs:complexType name="scopeType" mixed="true"> <xs:choice minOccurs="0"> <xs:element name="important" type="xs:string"/> </xs:choice> <xs:attribute name="name" type="xs:string" use="required"/> </xs:complexType> </xs:schema> A sample XML looks like below: 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 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="test.xsd" name="inlcudedScope"> This is an <important>included</important> scope. </scope> The other schemas are: xml.xsd <?xml version='1.0'?> <xs:schema targetNamespace="http://www.w3.org/XML/1998/namespace" xmlns:xs="http://www.w3.org/2001/XMLSchema" xml:lang="en"> <xs:annotation> <xs:documentation> See http://www.w3.org/XML/1998/namespace.html and http://www.w3.org/TR/REC-xml for information about this namespace. This schema document describes the XML namespace, in a form suitable for import by other schema documents. Note that local names in this namespace are intended to be defined only by the World Wide Web Consortium or its subgroups. The following names are currently defined in this namespace and should not be used with conflicting semantics by any Working Group, specification, or document instance: base (as an attribute name): denotes an attribute whose value provides a URI to be used as the base for interpreting any relative URIs in the scope of the element on which it appears; its value is inherited. This name is reserved by virtue of its definition in the XML Base specification. id (as an attribute name): denotes an attribute whose value should be interpreted as if declared to be of type ID. The xml:id specification is not yet a W3C Recommendation, but this attribute is included here to facilitate experimentation with the mechanisms it proposes. Note that it is _not_ included in the specialAttrs attribute group. lang (as an attribute name): denotes an attribute whose value is a language code for the natural language of the content of any element; its value is inherited. This name is reserved by virtue of its definition in the XML specification. space (as an attribute name): denotes an attribute whose value is a keyword indicating what whitespace processing discipline is intended for the content of the element; its value is inherited. This name is reserved by virtue of its definition in the XML specification. Father (in any context at all): denotes Jon Bosak, the chair of the original XML Working Group. This name is reserved by the following decision of the W3C XML Plenary and XML Coordination groups: In appreciation for his vision, leadership and dedication the W3C XML Plenary on this 10th day of February, 2000 reserves for Jon Bosak in perpetuity the XML name xml:Father </xs:documentation> </xs:annotation> <xs:annotation> <xs:documentation>This schema defines attributes and an attribute group suitable for use by schemas wishing to allow xml:base, xml:lang or xml:space attributes on elements they define. To enable this, such a schema must import this schema for the XML namespace, e.g. as follows: <schema . . .> . . . <import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/03/xml.xsd"/> Subsequently, qualified reference to any of the attributes or the group defined below will have the desired effect, e.g. <type . . .> . . . <attributeGroup ref="xml:specialAttrs"/> will define a type which will schema-validate an instance element with any of those attributes</xs:documentation> </xs:annotation> <xs:annotation> <xs:documentation>In keeping with the XML Schema WG's standard versioning policy, this schema document will persist at http://www.w3.org/2005/08/xml.xsd. At the date of issue it can also be found at http://www.w3.org/2001/xml.xsd. The schema document at that URI may however change in the future, in order to remain compatible with the latest version of XML Schema itself, or with the XML namespace itself. In other words, if the XML Schema or XML namespaces change, the version of this document at http://www.w3.org/2001/xml.xsd will change accordingly; the version at http://www.w3.org/2005/08/xml.xsd will not change. </xs:documentation> </xs:annotation> <xs:attribute name="lang"> <xs:annotation> <xs:documentation>This attribute MAY be inserted in documents to specify the language used in the contents and attribute values of any element in an XML document. The values are the ISO 2- and 3-letter codes. An empty string value means the 'un-declaration' of xml:lang. See RFC 3066 at http://www.ietf.org/rfc/rfc3066.txt and the IANA registry at http://www.iana.org/assignments/lang-tag-apps.htm for further information.</xs:documentation> </xs:annotation> <xs:simpleType> <xs:union memberTypes="xs:language"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:enumeration value=""/> </xs:restriction> </xs:simpleType> </xs:union> </xs:simpleType> </xs:attribute> <xs:attribute name="space"> <xs:annotation> <xs:documentation>This attribute is attached to an element to signal an intention that in that element, white space should be preserved by applications. Possible values are "default" and "preserve". </xs:documentation> </xs:annotation> <xs:simpleType> <xs:restriction base="xs:NCName"> <xs:enumeration value="default"> <xs:annotation> <xs:documentation>Specifies that the whitespaces should not be preserved.</xs:documentation> </xs:annotation> </xs:enumeration> <xs:enumeration value="preserve"> <xs:annotation> <xs:documentation>Specifies that the whitespaces should be preserved.</xs:documentation> </xs:annotation> </xs:enumeration> </xs:restriction> </xs:simpleType> </xs:attribute> <xs:attribute name="base" type="xs:anyURI"> <xs:annotation> <xs:documentation>The attribute xml:base may be inserted in XML documents to specify a base URI other than the base URI of the document or external entity. See http://www.w3.org/TR/xmlbase/ for information about this attribute.</xs:documentation> </xs:annotation> </xs:attribute> <xs:attribute name="id" type="xs:ID"> <xs:annotation> <xs:documentation>Defines an ID value without the need of a DTD or schmea. See http://www.w3.org/TR/xml-id/ for information about this attribute.</xs:documentation> </xs:annotation> </xs:attribute> <xs:attributeGroup name="specialAttrs"> <xs:attribute ref="xml:base"/> <xs:attribute ref="xml:lang"/> <xs:attribute ref="xml:space"/> </xs:attributeGroup> </xs:schema> xinclude.xsd <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.w3.org/2001/XInclude" xmlns:xi="http://www.w3.org/2001/XInclude" finalDefault="extension"> <xs:annotation> <xs:documentation> Not normative, but may be useful. See the REC http://www.w3.org/TR/XInclude for definitive information about this namespace. </xs:documentation> </xs:annotation> <xs:element name="include" type="xi:includeType"/> <xs:complexType name="includeType" mixed="true"> <xs:choice minOccurs="0" maxOccurs="unbounded"> <xs:element ref="xi:fallback"/> <xs:any namespace="##other" processContents="lax"/> <xs:any namespace="##local" processContents="lax"/> </xs:choice> <xs:attribute name="href" use="optional" type="xs:anyURI"/> <xs:attribute name="parse" use="optional" default="xml" type="xi:parseType"/> <xs:attribute name="xpointer" use="optional" type="xs:string"/> <xs:attribute name="encoding" use="optional" type="xs:string"/> <xs:attribute name="accept" use="optional" type="xs:string"/> <xs:attribute name="accept-language" use="optional" type="xs:string"/> <xs:anyAttribute namespace="##other" processContents="lax"/> </xs:complexType> <xs:simpleType name="parseType"> <xs:restriction base="xs:token"> <xs:enumeration value="xml"/> <xs:enumeration value="text"/> </xs:restriction> </xs:simpleType> <xs:element name="fallback" type="xi:fallbackType"/> <xs:complexType name="fallbackType" mixed="true"> <xs:choice minOccurs="0" maxOccurs="unbounded"> <xs:element ref="xi:include"/> <xs:any namespace="##other" processContents="lax"/> <xs:any namespace="##local" processContents="lax"/> </xs:choice> <xs:anyAttribute namespace="##other" processContents="lax"/> </xs:complexType> </xs:schema> Best Regards, George --------------------------------------------------------------------- George Cristian Bina - http://aboutxml.blogspot.com/ <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger http://www.oxygenxml.com Timothy Reaves wrote:
On Tue, July 17, 2007 16:13, George Cristian Bina wrote:
Dear Timothy,
oXygen has an option "Enable XInclude processing" that I believe is enabled by default. When that is enables the validation against XML Schema is performed after XInclude processing, that means the XML Schema should not care about defining the xi:include element but it should take into account that the included fragment will have an xml:base attribute pointing to the location it was included from and probably also an xml:lang. So for instance if you want to have scope elements inside scopes and you plan to include scope elements from other documents using XInclude then you should define xml:base (and xml:lang) to be allowed in the scope element.
When the XInclude processing is not enabled then oXygen will validate the document as it is against the specified XML Schema. In that case you need to refer to the xi:include element inside the schema, as in your sample. The problem in your case is the wrong namespace that you used in import, the correct nemespace is http://www.w3.org/2001/XInclude, that is not with 2003.
Best Regards, George
Do you have a sample document that shows this working correctly?
_______________________________________________ oXygen-user mailing list oXygen-user@oxygenxml.com http://www.oxygenxml.com/mailman/listinfo/oxygen-user

On Fri, July 20, 2007 06:20, George Cristian Bina wrote:
Dear Timothy,
Ok, I created a full working sample starting from your schema fragment. Basically we define a "scopes" element that can contain more "scope" elements. A "scope" element has mixed content and can contain "important" elements.
All the sample files are available also in an archive here http://www.oxygenxml.com/update/xincludeWithSchema.zip
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? 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?

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
participants (2)
-
George Cristian Bina
-
Timothy Reaves