This question is regarding how EntityResolver works with schemaLocation
with two systemId for different namespaces.
I used to have:
SAXParser p = new SAXParser();
p.setProperty
("http://apache.org/xml/properties/schema/external-schemaLocation",
"namespaceInSchema1 file:///c:/schema1.xsd namespaceInSchema2
file:///c:/schema2.xsd");
The parser validates fine. Now I want to implement my own EntityResolver,
so:
I have:
p.setProperty
("http://apache.org/xml/properties/schema/external-schemaLocation",
"namespaceInSchema1 id1 namespaceInSchema2 id2");
Then, in resolveEntity() method, I have:
String path = null;
InputSource in = null;
System.out.println("systemId: " + systemId);
if ( systemId.equals("id1") )
path = "c:/schema1.xsd";
else if ( systemId.equals("id2") )
path = "c:/schema2.xsd";
else
return in;
System.out.println(path);
//open file with path and read file into an inputStream
//using inputStream to make inputSource in
return in;
I am expecting the println method to print on screen:
systemId: id1
c:/schema1.xsd
systemId: id2
c:/schema2.xsd
However, I got:
systemId: id2
c:/schema2.xsd
systemId: c:/schema1.xsd
How does this work? Where is my "id1"? Anybody has an idea? Thanks a
lot.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]