[jdom-interest] malformed URL exception exception in saxbuilder.build due to unreachable URL
palmercliff at gmail.com
Fri Feb 10 10:32:16 PST 2012
Rolf, that sounds like a great idea.
Another validation process that would help when doing XML exploration
(i.e you don't know what is in the data and are trying to find out)
would be to throw an exception of the string is null and not use the
"null pointer" exception.
Thanks again for your help.
On Fri, Feb 10, 2012 at 8:22 AM, Rolf Lear <jdom at tuis.net> wrote:
> Hi Cliff.
> That would be a mystery, but my suspicion is that it has not worked at
> all... if it *did* work then there are other problems ... ;-)
> I suspect that everything has been failing - maybe the first record from
> the database had an xmlns, and it has been a red-herring for you.
> I did run some test code through, and it causes similar errors regardless
> of the actual XML content.
> I wonder if it would help if we put a validation process in the
> SAXBuilder.build(String) method that inspected the string, and if the first
> non-white character is '<' it throws an exception.... that should catch all
> instances where XML content is supplied to the method, since '<' is never
> valid in a URI..... and it is always the first character in any valid XML
> getting an exception: MalformedURLException: "SAXBuilder.build(String)
> expects a String URI not XML Content" would be a whole lot easier to manage
> than the exception you have....
> On Fri, 10 Feb 2012 07:35:43 -0500, cliff palmer <palmercliff at gmail.com>
>> Rolf, that worked - it's mysterious that the version in my code
>> (passing the string) worked until there was a URL, but I can live with
>> mysteries in light of working code :).
>> On Thu, Feb 9, 2012 at 6:44 PM, Rolf Lear <jdom at tuis.net> wrote:
>>> Hi Cliff.
>>> I think the problem is that the content of the column 'xml_contents' of
>>> table 'xml_table' is actual XML data.... not a file name/URI.
>>> I think what you want to do is:
>>> String xmlcontent = rs.getString(2);
>>> StringReader reader = new StringReader(xmlcontent);
>>> xmlDoc = saxBuilder.build(reader);
>>> See http://jdom.org/docs/faq.html#a0210
More information about the jdom-interest