[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: namespace-unawareness
On 11/17/2010 1:35 PM, Martin Honnen wrote: > > I think the Java DOM APIs can handle that: > > DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); > DocumentBuilder db = dbf.newDocumentBuilder(); > Document doc = db.parse(new InputSource( > new StringReader("<related-article xlink:href=\"xxx\" />"))); > > System.out.println(doc.getDocumentElement().getAttribute("xlink:href")); > That's interesting: I was attempting to parse using Xerces as a SAX parser and I got an error: 2010-11-17 11:41:19,855 ERROR org.xml.sax.SAXParseException: The prefix "xlink" for attribute "xlink:href" associated with an element type "related-article" is not bound. Perhaps this was due to having passed the SAX Source to an xslt transformer (saxon). I suppose it's possible saxon changed the namespace-awareness after I had already set it? Anyway, it sounds like this whole course of action may be dubious and my only recourse is to tell the client: add declarations to your xml, or perhaps to fix it myself by wrapping an outer element with the missing decls. However, although the question seems to be purely academic at this point, I'm still wondering why there is an option for namespace-aware=false. Perhaps at some point in the past there was an idea of backwards compatibility that is no longer relevant? -Mike
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] |
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|