You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by bu...@apache.org on 2001/06/28 00:45:47 UTC
[Bug 2372] New: - Import statement without schemaLocation causes parser to throw Exception
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=2372
*** shadow/2372 Wed Jun 27 15:45:47 2001
--- shadow/2372.tmp.9141 Wed Jun 27 15:45:47 2001
***************
*** 0 ****
--- 1,206 ----
+ +============================================================================+
+ | Import statement without schemaLocation causes parser to throw Exception |
+ +----------------------------------------------------------------------------+
+ | Bug #: 2372 Product: Xerces-J |
+ | Status: NEW Version: 1.4.1 |
+ | Resolution: Platform: PC |
+ | Severity: Normal OS/Version: Windows NT/2K |
+ | Priority: Other Component: Schema-Structures |
+ +----------------------------------------------------------------------------+
+ | Assigned To: xerces-j-dev@xml.apache.org |
+ | Reported By: mdiiorio@iss.net |
+ | CC list: Cc: |
+ +----------------------------------------------------------------------------+
+ | URL: |
+ +============================================================================+
+ | DESCRIPTION |
+ From http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/#element-import
+
+ "NOTE: Since both the namespace and schemaLocation [attribute] are optional, a
+ bare <import/>
+ information item is allowed. This simply allows unqualified reference to
+ foreign components
+ with no target namespace without giving any hints as to where to find them. "
+
+ If I have an import statement that does not have a schemaLocation attribute,
+ Xerces
+ blows up with the following exception. The only difference between the working
+ and
+ non-working version of animalWidget.xsd is the following line:
+
+ <import namespace='http://www.foo.com/widget'/>
+
+ The non-working version of animalWidget.xsd has an import statement that leaves
+ off
+ the schemaLocation attribute.
+
+ Note: This example would not correctly validate even if the import bug was
+ fixed. I
+ stumbled on this bug while playing with the new schemaLocation property added
+ in 1.4.1.
+ To make this example complete I would have to include the Java code I was
+ using. I didn't
+ think it was necessary to include the code to describe the bug, but I can give
+ to you if you want.
+
+
+ C:\dev\CommonPolicyEditor\Dev\SchemaDev>c:\jdk1.3\bin\java -classpath
+ c:\dev\lib\xerces\xerces.jar;c:\dev\lib\xerces\xercesSamples.jar sax.SAXCount -
+ v testWidget.xml
+ [Warning] :0:0: File "" not found.
+ org.xml.sax.SAXException: Stopping after fatal error: File "" not found.
+ at org.apache.xerces.framework.XMLParser.reportError
+ (XMLParser.java:1228)
+ at
+ org.apache.xerces.readers.DefaultEntityHandler.startReadingFromDocument
+ (DefaultEntityHandler.java:499)
+ at org.apache.xerces.framework.XMLParser.parseSomeSetup
+ (XMLParser.java:312)
+ at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1080)
+ at org.apache.xerces.validators.schema.TraverseSchema.traverseImport
+ (TraverseSchema.java:2016)
+ at org.apache.xerces.validators.schema.TraverseSchema.doTraverseSchema
+ (TraverseSchema.java:698)
+ at org.apache.xerces.validators.schema.TraverseSchema.<init>
+ (TraverseSchema.java:518)
+ at org.apache.xerces.validators.common.XMLValidator.resolveSchemaGrammar
+ (XMLValidator.java:2753)
+ at org.apache.xerces.validators.common.XMLValidator.parseSchemas
+ (XMLValidator.java:2648)
+ at
+ org.apache.xerces.validators.common.XMLValidator.bindNamespacesToElementAndAttri
+ butes(XMLValidator.java:2589)
+ at org.apache.xerces.validators.common.XMLValidator.callStartElement
+ (XMLValidator.java:1142)
+ at org.apache.xerces.framework.XMLDocumentScanner.scanElement
+ (XMLDocumentScanner.java:1862)
+ at
+ org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch
+ (XMLDocumentScanner.java:1005)
+ at org.apache.xerces.framework.XMLDocumentScanner.parseSome
+ (XMLDocumentScanner.java:381)
+ at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1081)
+ at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1122)
+ at sax.SAXCount.print(SAXCount.java:158)
+ at sax.SAXCount.main(SAXCount.java:392)
+ [Error] testWidget.xml:4:80: Schema error: Could not get the doc root for
+ imported Schema file: ,.
+ [Error] testWidget.xml:4:80: Schema error: could not resolve URI :
+ http://www.foo.com/widget to a SchemaGrammar in getTypeInfoFromNS.
+ [Error] testWidget.xml:4:80: Schema error: ComplexType 'LemurWidget': Could
+ notfind base type Widget in schema http://www.foo.com/widget.
+ [Error] testWidget.xml:5:21: General Schema Error: Grammar with uri 2:
+ http://www.foo.com/widget , can not be found.
+ [Error] testWidget.xml:5:21: Element type "widget:comment" must be declared.
+ [Error] testWidget.xml:6:10: Element type "bar" must be declared.
+ [Error] testWidget.xml:7:10: Element type "foo" must be declared.
+ [Error] testWidget.xml:8:10: Element type "foo" must be declared.
+ [Error] testWidget.xml:9:10: Element type "bar" must be declared.
+ [Error] testWidget.xml:10:10: Element type "foo" must be declared.
+ [Error] testWidget.xml:11:10: Element type "bar" must be declared.
+ testWidget.xml: 1111 ms (8 elems, 4 attrs, 0 spaces, 59 chars)
+
+
+
+ widget.xsd
+ ----------
+ <schema xmlns='http://www.w3.org/2001/XMLSchema'
+ targetNamespace='http://www.foo.com/widget'
+ xmlns:widget='http://www.foo.com/widget'
+ version='1.0'
+ elementFormDefault='qualified'
+ attributeFormDefault='unqualified'>
+
+
+ <complexType name='Onething'>
+ <sequence>
+ <element name='tag' type='string' minOccurs='1'
+ maxOccurs='unbounded'/>
+ </sequence>
+ </complexType>
+
+ <complexType name='Widget'>
+ <sequence>
+ <element name='comment' type='string' minOccurs='1' maxOccurs='1'/>
+ </sequence>
+ </complexType>
+ </schema>
+
+
+ animalWidget.xsd (working)
+ --------------------------
+ <schema xmlns='http://www.w3.org/2001/XMLSchema'
+ targetNamespace='http://www.foo.com/animalWidget'
+ xmlns:animalWidget='http://www.foo.com/animalWidget'
+ xmlns:widget='http://www.foo.com/widget'
+ version='1.0'
+ elementFormDefault='qualified'
+ attributeFormDefault='unqualified'>
+
+ <import namespace='http://www.foo.com/widget'
+ schemaLocation='file:widget.xsd'/>
+
+ <element name='test' type='animalWidget:LemurWidget'/>
+
+ <complexType name='LemurWidget'>
+ <complexContent>
+ <extension base='widget:Widget'>
+ <choice minOccurs='0' maxOccurs='unbounded'>
+ <sequence>
+ <element name='foo' type='string' minOccurs='0'
+ maxOccurs='unbounded'/>
+ <element name='bar' type='string' minOccurs='0'
+ maxOccurs='unbounded'/>
+ </sequence>
+ </choice>
+ </extension>
+ </complexContent>
+ </complexType>
+ </schema>
+
+
+ animalWidget.xsd (non-working)
+ ------------------------------
+ <schema xmlns='http://www.w3.org/2001/XMLSchema'
+ targetNamespace='http://www.foo.com/animalWidget'
+ xmlns:animalWidget='http://www.foo.com/animalWidget'
+ xmlns:widget='http://www.foo.com/widget'
+ version='1.0'
+ elementFormDefault='qualified'
+ attributeFormDefault='unqualified'>
+
+ <import namespace='http://www.foo.com/widget'/>
+
+ <element name='test' type='animalWidget:LemurWidget'/>
+
+ <complexType name='LemurWidget'>
+ <complexContent>
+ <extension base='widget:Widget'>
+ <choice minOccurs='0' maxOccurs='unbounded'>
+ <sequence>
+ <element name='foo' type='string' minOccurs='0'
+ maxOccurs='unbounded'/>
+ <element name='bar' type='string' minOccurs='0'
+ maxOccurs='unbounded'/>
+ </sequence>
+ </choice>
+ </extension>
+ </complexContent>
+ </complexType>
+ </schema>
+
+
+ testWidget.xsd
+ --------------
+ <test xmlns='http://www.foo.com/animalWidget'
+ xmlns:widget='http://www.foo.com/widget'
+ xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
+ xsi:schemaLocation='http://www.foo.com/animalWidget file:animalWidget.xsd'>
+ <widget:comment>foo</widget:comment>
+ <bar>frob</bar>
+ <foo>ack</foo>
+ <foo>qux</foo>
+ <bar>eep</bar>
+ <foo>quux</foo>
+ <bar>oop</bar>
+ </test>
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org