[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: namespace-unawareness

  • From: Michael Sokolov <sokolov@ifactory.com>
  • To: xml-dev@lists.xml.org
  • Date: Wed, 17 Nov 2010 21:25:42 -0500

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!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.