xom-interest AT lists.ibiblio.org
Subject: XOM API for Processing XML with Java
List archive
Re: [XOM-interest] XInclusion produdes invalid document
- From: Elliotte Harold <elharo AT metalab.unc.edu>
- To: Andrew Thompson <lordpixel AT mac.com>
- Cc: xom-interest AT lists.ibiblio.org
- Subject: Re: [XOM-interest] XInclusion produdes invalid document
- Date: Sun, 06 Mar 2005 15:45:12 -0500
Andrew Thompson wrote:
* cosmetically, we've lost the newlines after the comment
You're not providing sufficient information to be sure, but it sounds like these comments come from the document prolog. If so, it's the parser that loses the newlines, not XInclude.
* the div has picked up an xmlns="" which makes it fail w3 validation. This is a Xerces bug, I think... because I've seen it when using XSLT before
That's weird. It's probably something that's required in your case due to things you haven't told us, but it might be my bug. Hard to tell without seeing the full example. I'd be surprised if it were a Xerces bug though.
* The killer is this xml:base="file:///path/on/my/local/harddisk/website%20bits/sidebar.xml"
EHR, I notice you didn't mention this in your article @ http://cafe.elharo.com/xml/xinclude/ but from a quick read of the XInclude spec this seems to be expected (XInclude spec, section 4.5.5).
That's correct. It is expected. XOM is allowed to compute relative URIs instead. So far I don't implement that, and it's not exactly clear what that would mean if I did. (I could do it if the parent element had an xml:base attribute that contained an absolute URI, but if the document is simply written out to an arbitrary location, the only way to get the base URI right is to write an absolute URI).
This is horrible from a workflow perspective though... Quite apart from it also failing w3 validation, I want to resolve XIncludes on my local system before uploading these files to my web server. So I really don't want references to my local filesystem littered all over these documents. Even if today's tools ignore xml:base, I don't want my local disk names published!
You should perhaps ask the W3C for an option to skip base URI fixup.
In an attempt to bring thing back on topic, is there anything I can do in XOM to try to suppress this stuff? (the base and the xmlns?). Is there a better XML parser to use for this than the Xerces that's bundled with JDK 1.4.2?
The xmlns stuff is weird. See if you can produce a simple example of that. I suspect it's either my bug or it's necessary in your context.
You could write a post-process that stripped the xml:base attributes. It would be easiest to do this using XSLT or (in XOM 1.1) XPath:
Nodes nodes = doc.query("//*[@xml:base]");
for (int i = 0; i < nodes.size(); i++) {
Element e = (Element) node;
e.removeAttribute("xml:base", Namespace.XML_NAMESPACE);
}
--
Elliotte Rusty Harold elharo AT metalab.unc.edu
XML in a Nutshell 3rd Edition Just Published!
http://www.cafeconleche.org/books/xian3/
http://www.amazon.com/exec/obidos/ISBN=0596007647/cafeaulaitA/ref=nosim
-
[XOM-interest] XInclusion produdes invalid document,
Andrew Thompson, 03/06/2005
-
Re: [XOM-interest] XInclusion produdes invalid document,
Elliotte Harold, 03/06/2005
-
Re: [XOM-interest] XInclusion produdes invalid document,
Andrew Thompson, 03/06/2005
- Re: [XOM-interest] XInclusion produdes invalid document, Elliotte Harold, 03/06/2005
-
Re: [XOM-interest] XInclusion produdes invalid document,
Elliotte Harold, 03/06/2005
-
Re: [XOM-interest] XInclusion produdes invalid document,
Andrew Thompson, 03/06/2005
-
Re: [XOM-interest] XInclusion produdes invalid document,
Elliotte Harold, 03/06/2005
-
Re: [XOM-interest] XInclusion produdes invalid document,
Andrew Thompson, 03/06/2005
- Re: [XOM-interest] XInclusion produdes invalid document, Elliotte Harold, 03/07/2005
- Re: [XOM-interest] XInclusion produdes invalid document, John Cowan, 03/07/2005
-
Re: [XOM-interest] XInclusion produdes invalid document,
Andrew Thompson, 03/06/2005
-
Re: [XOM-interest] XInclusion produdes invalid document,
Elliotte Harold, 03/06/2005
-
Re: [XOM-interest] XInclusion produdes invalid document,
Andrew Thompson, 03/06/2005
-
Re: [XOM-interest] XInclusion produdes invalid document,
Andrew Thompson, 03/07/2005
- Re: [XOM-interest] XInclusion produdes invalid document, Elliotte Harold, 03/07/2005
-
Re: [XOM-interest] XInclusion produdes invalid document,
Andrew Thompson, 03/06/2005
-
Re: [XOM-interest] XInclusion produdes invalid document,
Elliotte Harold, 03/06/2005
Archive powered by MHonArc 2.6.24.