tksk / jing-trang

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

typo in com.thaiopensource.resolver.xml.sax.SAX.EntityResolverImpl.resolveEntity(#4) #106

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. download the attached actions.xml & TranslatorBugTest.java to the same
directory
2. compile them against trunk or the release from 2009 :
   javac -cp lib/trang.jar:lib/jing.jar TranslatorBugTest.java
3. run the sample program
   java -cp lib/trang.jar:lib/jing.jar:. TranslatorBugTest actions.xml

What is the expected output?
            DummyEntityResolver.resolveEntity([dtd],null,actions.xml,actions.dtd);

and then a stack-trace starting with a RuntimeException saying:
 YES ! I have been called as expected !!!

What do you see instead?

The wrong method for an EntityResolver2 is called :
  DummyEntityResolver.resolveEntity(null,file:/MY_PATH/actions.dtd)

And then there is the UnsupportedOperationException :

  Exception in thread "main" java.lang.UnsupportedOperationException: I AM
AN ENTITYRESOLVER2 !!
    at
TranslatorBugTest$DummyEntityResolver.resolveEntity(TranslatorBugTest.java:49)
    at
com.thaiopensource.resolver.xml.sax.SAX$EntityResolverWrapper.resolve(SAX.java:6
5)
    at
com.thaiopensource.resolver.SequenceResolver.resolve(SequenceResolver.java:18)
    at
com.thaiopensource.resolver.xml.sax.SAX$EntityResolverImpl.resolveEntity(SAX.jav
a:184)
    at
com.sun.org.apache.xerces.internal.util.EntityResolver2Wrapper.resolveEntity(Ent
ityResolver2Wrapper.java:174)
    at
com.sun.org.apache.xerces.internal.impl.XMLEntityManager.resolveEntity(XMLEntity
Manager.java:701)
    at
com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDispatcher.dis
patch(XMLDocumentScannerImpl.java:1019)
    at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocum
ent(XMLDocumentFragmentScannerImpl.java:368)
    at
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configu
ration.java:834)
    at
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configu
ration.java:764)
    at
com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
    at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXPa
rser.java:1242)
    at com.thaiopensource.relaxng.input.xml.Inferrer.infer(Inferrer.java:226)
    at
com.thaiopensource.relaxng.input.xml.XmlInputFormat.load(XmlInputFormat.java:28)
    at
com.thaiopensource.relaxng.input.AbstractMultiInputFormat.load(AbstractMultiInpu
tFormat.java:14)
    at TranslatorBugTest.main(TranslatorBugTest.java:73)

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

20090818 on Mac OS X

Please provide any additional information below.

In com.thaiopensource.resolver.xml.sax.SAX, line 176
there is a test for the name equal "[doc]"
   a) I've never seen a resolveEntity() with the name equal to doc
   b) while stepping through the code, you'll see that the actual name
provided by the Xerces parser is [dtd] as expected from the documentation :
http://java.sun.com/javase/6/docs/api/org/xml/sax/ext/EntityResolver2.html#resol
veEntity%28java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang
.String%29

So I'll advise you to change the test to 
 if ("[dtd]".equals(name))
...

Thanks,

Original issue reported on code.google.com by neri...@wanadoo.fr on 28 Mar 2010 at 5:21

Attachments: