You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Howard Roberts <hr...@twowaytv.co.uk> on 2005/07/28 10:36:08 UTC

importing schemas

Hi there,

I'm having trouble importing multiple schemas for a project I'm working
on.

The main schema starts as below:

<xs:schema targetNamespace="http://www.foo.com/xml"
xmlns:imp="http://www.import.com/xml"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.foo.com/xml" elementFormDefault="qualified">

<xs:import namespace="http://www.w3.org/XML/1998/namespace"
schemaLocation="http://www.w3.org/2001/03/xml.xsd"/>
<xs:import namespace="http://www.import.com/xml"
schemaLocation="http://www.import.com/schemas/xmls/importedSchema.xsd"/>

...

</xs:schema>


importedSchema.xsd also imports a schema:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns="http://www.import.com/xml"
           targetNamespace="http://www.import.com/xml"
           elementFormDefault="qualified"
           attributeFormDefault="unqualified">

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


The application parsing instance documents does not have visibility of
any of these schemas on the internet. I set the parser to reference
local copies as below:

saxReader.setFeature("http://apache.org/xml/features/validation/schema",
true);
saxReader.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLan
guage",
		 "http://www.w3.org/2001/XMLSchema");
saxReader.setProperty("http://java.sun.com/xml/jaxp/properties/schemaSou
rce",
		 mainSchema.getPath());
saxReader.setProperty("http://apache.org/xml/properties/schema/external-
schemaLocation",
        		 "http://www.w3.org/XML/1998/namespace" + " " +
xmlLangSchema.getPath());
saxReader.setProperty("http://apache.org/xml/properties/schema/external-
schemaLocation",
          		 "http://www.import.com/xml" + " " +
importedSchema.getPath());


(where saxReader is a org.dom4j.io.SAXReader)

Xerces has 2 external-schemaLocation properties set. As I've illustrated
there are three import statements: two in the main schema document and
one in importedSchema. It seems xerces correctly ignores the urls of the
import statements of the main schema and uses the file system version as
instructed, but it looks like xerces is not doing the same for the
imported schema. Therefore, when my application attempts to parse an
instance document the error below is found.

Is this a bug in xerces, am I missing something/made a mistake, or is
this how imported schemas are meant to work? I'm using xerces v2.6.2.

Thanks in advance for any help,

Howard.


org.xml.sax.SAXParseException: src-resolve: Cannot resolve the name
'xml:lang' to a(n) 'attribute declaration' component.
	at
com.foo.app.tv.xml.ErrorHandlerImpl.error(ErrorHandlerImpl.java:29)
	at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown
Source)
	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown
Source)
	at
org.apache.xerces.impl.xs.traversers.XSDHandler.reportSchemaError(Unknow
n Source)
	at
org.apache.xerces.impl.xs.traversers.XSDHandler.getGlobalDecl(Unknown
Source)
	at
org.apache.xerces.impl.xs.traversers.XSDAttributeTraverser.traverseLocal
(Unknown Source)
	at
org.apache.xerces.impl.xs.traversers.XSDAbstractTraverser.traverseAttrsA
ndAttrGrps(Unknown Source)
	at
org.apache.xerces.impl.xs.traversers.XSDComplexTypeTraverser.traverseSim
pleContent(Unknown Source)
	at
org.apache.xerces.impl.xs.traversers.XSDComplexTypeTraverser.traverseCom
plexTypeDecl(Unknown Source)
	at
org.apache.xerces.impl.xs.traversers.XSDComplexTypeTraverser.traverseLoc
al(Unknown Source)
	at
org.apache.xerces.impl.xs.traversers.XSDElementTraverser.traverseNamedEl
ement(Unknown Source)
	at
org.apache.xerces.impl.xs.traversers.XSDElementTraverser.traverseGlobal(
Unknown Source)
	at
org.apache.xerces.impl.xs.traversers.XSDHandler.traverseSchemas(Unknown
Source)
	at
org.apache.xerces.impl.xs.traversers.XSDHandler.parseSchema(Unknown
Source)
	at org.apache.xerces.impl.xs.XMLSchemaLoader.loadSchema(Unknown
Source)
	at
org.apache.xerces.impl.xs.XMLSchemaLoader.processJAXPSchemaSource(Unknow
n Source)
	at org.apache.xerces.impl.xs.XMLSchemaLoader.loadSchema(Unknown
Source)
	at
org.apache.xerces.impl.xs.XMLSchemaValidator.findSchemaGrammar(Unknown
Source)
	at
org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown
Source)
	at
org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown
Source)
	at
org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown
Source)
	at
org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scan
RootElementHook(Unknown Source)
	at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDis
patcher.dispatch(Unknown Source)
	at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unkno
wn Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown
Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown
Source)
	at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
	at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown
Source)












---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org