XML Schema with XInclude - xml:base attribute

This should cover W3C XML Schema, Relax NG and DTD related problems.
tatra603
Posts: 72
Joined: Fri Sep 17, 2004 10:53 am
Location: Prague, the Czech Republic, Europe

XML Schema with XInclude - xml:base attribute

Post by tatra603 » Wed Jan 18, 2006 4:18 pm

Hello!

I have a problem. I have XSD and XML valid to this shema. I want to use XInclude in XML to include "column" element, which is root element in other XML. XML processor (default in oXygen 7.0) does inclusion, but claims:

Description: E cvc-complex-type.3.2.2: Attribute 'xml:base' is not allowed to appear in element 'column'.

This is because XML processor automatically adds attribute called "xml:base" to the resulted XML document. Well, what should I do in XML Schema and XML to be again valid? In other words some example of two XML (one is included into other) and one XSD is welcome.

Element definition in my XSD is defined as follows:

<xs:element name="column">
<xs:complexType mixed="false">
<xs:attribute name="xmlName" use="required" type="xs:NCName"/>
<xs:attribute name="sqlName" use="required" type="xs:NCName"/>
<xs:attribute name="globalVariableName"/>
<xs:attribute name="charsetName"/>
<xs:attribute name="base" type="xs:anyURI" form="qualified" />
</xs:complexType>
</xs:element>

This XSD is valid. Root elemnt of XML has an attribute xmlns:xi="http://www.w3.org/2001/XInclude"

Can You help me, please?
Stepan
P.S. When I turn off validation in J2SE 1.5.0, fragment is included as expected.

george
Site Admin
Posts: 2101
Joined: Thu Jan 09, 2003 2:58 pm

Post by george » Wed Jan 18, 2006 4:42 pm

Hello Stepan,

You need first to import the schema for the xml namespace like:

<xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="xml.xsd"/>

if you place xml.xsd locally or

<xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2005/08/xml.xsd"/>


Then you can just add a reference to the xml:base attribute like
<xs:attribute ref="xml:base"/>

Best Regards,
George

tatra603
Posts: 72
Joined: Fri Sep 17, 2004 10:53 am
Location: Prague, the Czech Republic, Europe

Post by tatra603 » Wed Jan 18, 2006 5:10 pm

Great! It works. Thank You. Stepan

Post Reply