OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
Re: [xml-dev] 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?


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS