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 2002/04/24 16:53:31 UTC
DO NOT REPLY [Bug 8471] New: -
parseASURI work while parseASInputSource does not work
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=8471>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=8471
parseASURI work while parseASInputSource does not work
Summary: parseASURI work while parseASInputSource does not work
Product: Xerces2-J
Version: 2.0.1
Platform: PC
OS/Version: Windows NT/2K
Status: NEW
Severity: Normal
Priority: Other
Component: DOM
AssignedTo: xerces-j-dev@xml.apache.org
ReportedBy: george@sync.ro
I made a simple example of a schema including another schema. When I try to
parse it with the parseASURI method everything is ok, but when I use
parseASInputSource I get a warning saying that the included schema document
cannot be read. (It seems that the included document is resolved relative to
the working directory instead of the initial document systemID). If I put the
documents in the working directory then both methods work.
Here is the class for test:
...
package ro.sync.xml.schema;
import org.apache.xerces.parsers.*;
import org.apache.xerces.dom.DOMInputSourceImpl;
import org.apache.xerces.dom3.ls.DOMInputSource;
import java.io.*;
public class ParseTest {
public static void main(String[] args) {
try {
DOMASBuilderImpl p = new DOMASBuilderImpl();
System.out.println("About to parse AS URI");
p.parseASURI("data/includer.xsd");
System.out.println("About to parse AS Input Source");
StringBuffer buffer = new StringBuffer();
FileInputStream fis = new FileInputStream("data/includer.xsd");
int c = fis.read();
while (c >= 0) {
buffer.append((char)c);
c = fis.read();
}
DOMInputSource is = new DOMInputSourceImpl(
null,
new File("data/includer.xsd").toURL().toString(),
null,
new StringReader(buffer.toString()),
null
);
p.parseASInputSource(is);
} catch (Exception e) {
e.printStackTrace();
}
}
}
...
Here are the schema documents:
data/includer.xsd
...
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:include schemaLocation="included.xsd"/>
<xs:element name="includer">
<xs:simpleType>
<xs:restriction base="xs:string"/>
</xs:simpleType>
</xs:element>
</xs:schema>
...
data/included.xsd
...
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="included">
<xs:simpleType>
<xs:restriction base="xs:string"/>
</xs:simpleType>
</xs:element>
</xs:schema>
...
Here is the output
...
About to parse AS URI
About to parse AS Input Source
[Warning] :3:48: src-include.0: Failed to read included schema
document 'included.xsd'.
...
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org