visibility of imported schema

This should cover W3C XML Schema, Relax NG and DTD related problems.
solomono
Posts: 11
Joined: Tue Apr 05, 2005 7:46 pm

visibility of imported schema

Post by solomono » Tue Apr 19, 2005 2:15 am

hello genetlemen,
I have an instance document as follow
Expressions-XPATH.xml layer. file

<core:Layer xmlns:xpath="urn://com.eudoxus/Expressions-XPATH"
xmlns:core="urn://com.eudoxus/Core"
xmlns:java="urn://com.eudoxus/Java"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xsi:schemaLocation="urn://com.eudoxus/Expressions-XPATH Expressions-XPATH.xsd"
core:name="Expressions-XPATH"
core:abbreviatedName="xpath">
<core:roles>
<core:Role core:name="XPATHExpressionTypeManager" core:schemaType="xpath:XPATHExpressionTypeManager" core:extends="core:ExpressionTypeManager">
<core:attributes>
<core:Attribute core:name="functionInfo"/>
<core:Attribute core:name="predefinedVariableInfo"/>
</core:attributes>
</core:Role>
</core:roles>
......
</core:Layer>

which imports a schema Expressions-XPATH.xsd schema file

<xsd:schema xmlns="urn://com.eudoxus/Expressions-XPATH"
xmlns:xpath="urn://com.eudoxus/Expressions-XPATH"
xmlns:core="urn://com.eudoxus/Core"
xmlns:java="urn://com.eudoxus/Java"
elementFormDefault="qualified"
attributeFormDefault="qualified"
targetNamespace="urn://com.eudoxus/Expressions-XPATH"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<xsd:import namespace="urn://com.eudoxus/Core" schemaLocation="eudoxus:/Core/Core.xsd" />


<xsd:complexType name="XPATHFunction" abstract="true"
core:javaInterfaceName="com.eudoxus.expression.xpath.antlr.IXPATHFunction">
</xsd:complexType>
.......
</xsd:schema>

the schema above imports a another schema file in which I use the catalog
to resolve the location

I know this works because the schema validates with the import when I remove the import I obtain errors

The schema file imported is Core.xsd

<xsd:schema xmlns="urn://com.eudoxus/Core"
elementFormDefault="qualified"
xmlns:SOAP-ENV="http://www.w3.org/2002/06/soap-envelope"
targetNamespace="urn://com.eudoxus/Core"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:import namespace="http://www.w3.org/2002/06/soap-envelope" schemaLocation="eudoxus:/SOAP-Envelope/SOAP-Envelope.xsd"/>
<xsd:include schemaLocation="Component.xsd"/>
<xsd:include schemaLocation="Remote.xsd"/>
<xsd:include schemaLocation="Runtime.xsd"/>
<xsd:include schemaLocation="Event.xsd"/>
<xsd:include schemaLocation="ComponentManager.xsd"/>
<xsd:include schemaLocation="XML.xsd"/>
<xsd:include schemaLocation="Collection.xsd"/>
<xsd:include schemaLocation="Expression.xsd"/>
<xsd:include schemaLocation="Scripting.xsd"/>
<xsd:include schemaLocation="Metadata.xsd"/>
<xsd:include schemaLocation="Entity.xsd"/>
<xsd:include schemaLocation="Entity-Behavior.xsd"/>
<xsd:include schemaLocation="Entity-Metadata.xsd"/>
<xsd:include schemaLocation="StringManager.xsd"/>
<xsd:include schemaLocation="Transaction.xsd"/>
<xsd:include schemaLocation="Logging.xsd"/>
</xsd:schema>

includes among other files including

Metadata.xsd


<?xml version="1.0"?>
<xsd:schema xmlns="urn://com.eudoxus/Core"
xmlns:core="urn://com.eudoxus/Core"
elementFormDefault="qualified"
attributeFormDefault="qualified"
targetNamespace="urn://com.eudoxus/Core"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<xsd:include schemaLocation="Collection.xsd"/>
<xsd:include schemaLocation="Expression.xsd"/>
<xsd:include schemaLocation="Component.xsd"/>
<xsd:include schemaLocation="XML.xsd"/>

<xsd:element name="Layer" type="Layer"/>
<xsd:complexType name="Layer"
core:javaClassName="com.eudoxus.metadata.Layer">
<xsd:complexContent>
<xsd:extension base="core:Element">
<xsd:sequence>
<xsd:element name="roles" core:propertyName="role" minOccurs="0" type="core:RoleTypeCollection"/>
<xsd:element name="components" core:propertyName="componentType" minOccurs="0" type="core:ComponentTypeCollection"/>
<xsd:element name="extensions" core:propertyName="extension" minOccurs="0" type="core:ExtensionCollection"/>
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:ID"/>
<xsd:attribute name="abbreviatedName" use="required" type="xsd:string"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>

</xsd:schema>

which of course defines Layer the top level element in the first document

I obtain an error annot find the declaration of the element core:Layer.

There are other layer xml files in both the Core namespace and many others. In the core layer the layer xml files validate. When I change the
schemalocation attribute in the Expressions-XPATH layer file to point directly to the Core schema xsd it works but when it is done indirectly through the XPATH-Expression.xsd file which imports the Core schema xsd it does not work. This works in Stylus studio, and this
problem appears to be the last stumbling beforeles to I move Oxygen XML. Is there
any other way of accomplishing this. I have about 150 xml files with transitive
relationships among the schemas I really need to determine a mechanism to validate.

thanks
Solomon

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

Post by george » Wed Apr 20, 2005 7:01 pm

Hi Solomon,

If you use the external validation support and choose the Expressions-XPATH.xsd the validation should work. It works for the following samples:

master.xsd

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="ns1">
<xs:import namespace="ns2" schemaLocation="slave.xsd"/>
<xs:element name="x"/>
</xs:schema>
slave.xsd

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="ns2">
<xs:element name="test">
<xs:complexType>
<xs:sequence>
<xs:any/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="dummy"/>
</xs:schema>
test.xml

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<test xmlns="ns2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="ns1 master.xsd">
<dummy/>
</test>
Best Regards,
George

solomono
Posts: 11
Joined: Tue Apr 05, 2005 7:46 pm

visibility of imported schema

Post by solomono » Thu Apr 21, 2005 7:07 pm

Hi George,
When I use the the external validation I get the error
src-resolve: Cannot resove the name 'core:Component' to a(n) 'type definition'/@see....
I do not know what file this message is emanating from but I do not think it is the XML file I am validating because I purposely make the xml document invalid by change the document element I still get the same message.
Perhaps it is the definition in an schema in which core:Component is defined
as the base type of a complex type.
The problem may be because I use the xml catalog feature to resolve the schemalocation, which is probably not being made available to the
external validator.
For starters, am I using the schema mechanism in a proper manner, or is your normal validation mechanism flawed.
Next, is there a mechanism to completely control the external validation mechanism or at least add xml catalog/resolver support if that is the problem.
Also, the external validation mechanism mechanism does not report the
filename, lineno if available.
Finally, I would like to express my appreciation of the assistance you have
provided.
Thanks Again
Solomon

solomono
Posts: 11
Joined: Tue Apr 05, 2005 7:46 pm

visibility of imported schema

Post by solomono » Mon Apr 25, 2005 9:02 pm

Hi
I seemed to have stumbled on to the solution to the problem.

If I have a file
security.xml as such
<core:Layer xmlns:xpath="urn://com.eudoxus/Expressions-XPATH"
xmlns:core="urn://com.eudoxus/Core"
xmlns:java="urn://com.eudoxus/Java"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xsi:schemaLocation="urn://com.eudoxus/Expressions-XPATH Expressions-XPATH.xsd"
core:name="Expressions-XPATH"
core:abbreviatedName="xpath">
<core:roles>
<core:Role core:name="XPATHExpressionTypeManager" core:schemaType="xpath:XPATHExpressionTypeManager" core:extends="core:ExpressionTypeManager">
<core:attributes>
<core:Attribute core:name="functionInfo"/>
<core:Attribute core:name="predefinedVariableInfo"/>
</core:attributes>
</core:Role>
</core:roles>
</core:Layer>

that specifies a schema that does not directly define the top level element i.e the document element is defined in a schema which
it imports. The internal validator raises an the that core:Layer is not defined.

However if I define an element in the schema directly referrred to
by this document as such

<xsd:element name="Layer" type="core:Layer"/>



and then change the document root to

<xpath:Layer xmlns:xpath="urn://com.eudoxus/Expressions-XPATH"
xmlns:core="urn://com.eudoxus/Core"
xmlns:java="urn://com.eudoxus/Java"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xsi:schemaLocation="urn://com.eudoxus/Expressions-XPATH Expressions-XPATH.xsd"
core:name="Expressions-XPATH"
core:abbreviatedName="xpath">
<core:roles>
<core:Role core:name="XPATHExpressionTypeManager" core:schemaType="xpath:XPATHExpressionTypeManager" core:extends="core:ExpressionTypeManager">
<core:attributes>
<core:Attribute core:name="functionInfo"/>
<core:Attribute core:name="predefinedVariableInfo"/>
</core:attributes>
</core:Role>
</core:roles>
</xpath:Layer>
it works. Apparently the top level element must be directly defined
in the schema referenced by the schemaLocation attribute of the document
This solutions works for my as the element names are unimportant,
what must be invariant is the element type.

Well all is now well. All 150 xml documents validate.
thanks

Post Reply