[jdom-interest] BUG? SAXBuilder build(String) method throws MalformedURLException
Erik Earle
erikearle at hotmail.com
Fri Mar 14 09:56:25 PST 2003
With code:
<code>
XMLOutputter prettyOut = new XMLOutputter(" ",true);
String soap = "<foo></foo>";
try {
SAXBuilder sb = new SAXBuilder();
Document doc = sb.build(soap);
prettyOut.output(doc,System.out);
} catch(Exception e) {
e.printStackTrace();
}
</code>
I get:
<code>
org.jdom.JDOMException: Error in building: no protocol: <foo></foo>
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:373)
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:772)
at Testy.main(Testy.java:63)
Caused by: java.net.MalformedURLException: no protocol: <foo></foo>
at java.net.URL.<init>(URL.java:579)
at java.net.URL.<init>(URL.java:476)
at java.net.URL.<init>(URL.java:425)
at org.apache.xerces.impl.XMLEntityManager.startEntity(Unknown
Source)
at
org.apache.xerces.impl.XMLEntityManager.startDocumentEntity(Unknown Source)
at
org.apache.xerces.impl.XMLDocumentScannerImpl.setInputSource(Unknown Source)
at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.jdom.input.SAXBuilder.build(SAXBuilder.java:354)
... 2 more
Caused by: java.net.MalformedURLException: no protocol: <foo></foo>
...
</code>
BUT it works perfectly if I do:
<code>
XMLOutputter prettyOut = new XMLOutputter(" ",true);
String soap = "<foo></foo>";
try {
SAXBuilder sb = new SAXBuilder();
Document doc = sb.build( new StringReader(soap) );
prettyOut.output(doc,System.out);
} catch(Exception e) {
e.printStackTrace();
}
</code>
_________________________________________________________________
The new MSN 8: advanced junk mail protection and 2 months FREE*
http://join.msn.com/?page=features/junkmail
More information about the jdom-interest
mailing list