qiuwei / jing-trang

Automatically exported from code.google.com/p/jing-trang
Other
1 stars 1 forks source link

Error validating a multi-namespace document against XSD #113

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Using the attached file "tinysample.xml" as input

<?xml version="1.0" encoding="UTF-8"?>
<mets:mets xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:mets="http://www.loc.gov/METS/"
    xmlns="http://www.loc.gov/mods/v3"    
    xsi:schemaLocation="http://www.loc.gov/METS/ mets.xsd
http://www.loc.gov/mods/v3 mods-3-3.xsd">

    <mets:dmdSec ID="dmd1">
        <mets:mdWrap MDTYPE="OTHER">
            <mets:xmlData>
                <mods>
                    <titleInfo>
                        <title>Title</title>xxx
                    </titleInfo>
                </mods>
            </mets:xmlData>
        </mets:mdWrap>
    </mets:dmdSec>
    <mets:structMap>
        <mets:div DMDID="dmd1"/>
    </mets:structMap>
</mets:mets>

2. Validate the file with Jing version 20091111 using the command:

java -jar [path to]jing.jar mets.xsd tinysample.xml 

What is the expected output? What do you see instead?

I'd expect no output as the file is valid (under Xerces in oXygen and from
oNVDL from the command line, at least).

Instead I get:

Exception in thread "main" java.lang.NullPointerException
    at org.apache.xerces.impl.xs.XMLSchemaLoader.resolveDocument(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
com.thaiopensource.validate.xerces.ValidatorImpl.startElement(ValidatorImpl.java
:172)
    at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
    at
org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown
Source)
    at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.
dispatch(Unknown
Source)
    at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
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)
    at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
    at
com.thaiopensource.validate.ValidationDriver.validate(ValidationDriver.java:160)
    at com.thaiopensource.relaxng.util.Driver.doMain(Driver.java:154)
    at com.thaiopensource.relaxng.util.Driver.main(Driver.java:35)

What version of the product are you using? On what operating system?

Jing version 20091111 on Mac OS X Version 10.5.8 with Java 1.5.0_24

also on 

Jing version 20091111 on SunOS 5.9 with Java 1.6.0_18

Please provide any additional information below.

I do not get the same error when validating the same document from within
oXygen 11.2, build 2010031611 (i.e, xerces v. 2.9.1), or using oNVDL
version 20070517 (i.e, Jing version 20030619  + Xerces 2.9.0), or sun
msv-20081113 with the -xerces option (Xerces-J 1.44?) set.

Original issue reported on code.google.com by Catapan...@gmail.com on 27 May 2010 at 2:41

Attachments:

GoogleCodeExporter commented 8 years ago
Here it is a smaller sample to reproduce this issue:

test.xml

<root xmlns="http://www.example.com/root">
  <x:x xmlns:x="http://www.example.com/x"/>
</root>

or 

<r:root xmlns:r="http://www.example.com/root">
  <x:x xmlns:x="http://www.example.com/x"/>
</r:root>

test.xsd

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.example.com/root">
  <xs:element name="root"/>
</xs:schema>

The error appears when Xerces tries to locate a schema the for
http://www.example.com/x namespace. It is not related with the use of a prefix 
or of
the default namespace.

Original comment by georgebina76 on 31 May 2010 at 1:05

GoogleCodeExporter commented 8 years ago

Original comment by georgebina76 on 31 May 2010 at 1:44

GoogleCodeExporter commented 8 years ago
Thanks for reporting this problem, it is fixed in r2344.

Original comment by georgebina76 on 31 May 2010 at 2:02