xom-interest AT lists.ibiblio.org
Subject: XOM API for Processing XML with Java
List archive
- From: "Bradley S. Huffman" <hip AT cs.okstate.edu>
- To: Elliotte Rusty Harold <elharo AT metalab.unc.edu>
- Cc: xom-interest AT lists.ibiblio.org
- Subject: Re: [XOM-interest] XOM 1.0 alpha 1 is here
- Date: Wed, 09 Jun 2004 16:04:00 -0500
Elliotte Rusty Harold writes:
> At 10:20 AM -0500 6/9/04, Bradley S. Huffman wrote:
>
> >But is does change :-) Here's another use case, adding a base attribute to
> >the root element in file://home/hip/text_xom/test.xml
> >
> ><root xml:base="www.acme.org"><foo><bah/></foo></root>
> >
> >Document
> >--------
> >root base uri=file:/home/hip/test-xom/www.acme.org
> >foo base uri=file:/home/hip/test-xom/www.acme.org
> >bah base uri=file:/home/hip/test-xom/www.acme.org
>
> I'm sorry. I can't follow this. You're doing several weird things here:
>
> 1. www.acme.org is a relative URL that just happens to look like a
> host name. Did you mean to say http://www.acme.org? In which case
> you'd get very different results.
Actual no. The point was I create a element, attach it to a document,
remove it, and attach to another document and now getBaseURI() returns
something different then what I think most users would expect.
> 3. I don't know what you mean by far base uri below. :-(
Here's the code
import java.io.IOException;
import nu.xom.*;
public class TestBaseURI {
public static void main(String[] args) {
Builder builder0 = new Builder();
Builder builder1 = new Builder();
try {
Document doc0 = builder0.build("test.xml");
Element root0 = doc0.getRootElement();
System.out.println("\n");
System.out.println("Document");
System.out.println("--------");
printBaseURI(root0);
System.out.println("\n");
System.out.println("After creation");
System.out.println("--------------");
Element e1 = new Element("far");
printBaseURI(e1);
System.out.println("\n");
System.out.println("After appended to root");
System.out.println("----------------------");
root0.appendChild(e1);
printBaseURI(e1);
System.out.println("\n");
System.out.println("After removed from root");
System.out.println("-----------------------");
root0.removeChild(e1);
printBaseURI(e1);
System.out.println("\n");
System.out.println("Document");
System.out.println("--------");
Document doc1 = builder1.build("test1.xml");
Element root1 = doc1.getRootElement();
root1.appendChild(e1);
printBaseURI(root1);
}
catch (IOException ex) {
System.err.println(ex);
}
catch (ParsingException ex) {
System.err.println(ex);
}
}
public static void printBaseURI(Element el) {
String qname = el.getQualifiedName();
String base = el.getBaseURI();
System.out.println(qname + " base uri=" + base);
Elements elements = el.getChildElements();
for (int i = 0; i < elements.size(); i++) {
printBaseURI(elements.get(i));
}
}
}
Here's test.xml
<root xml:base="http://www.acme.org"><foo><bah/></foo></root>
Here's test1.xml
<bang><boom><ding/></boom></bang>
And here's the output
Document
--------
root base uri=http://www.acme.org
foo base uri=http://www.acme.org
bah base uri=http://www.acme.org
After creation
--------------
far base uri=
After appended to root
----------------------
far base uri=http://www.acme.org
After removed from root
-----------------------
far base uri=file:/home/hip/test-xom/test.xml
Document
--------
bang base uri=file:/home/hip/test-xom/test1.xml
boom base uri=file:/home/hip/test-xom/test1.xml
ding base uri=file:/home/hip/test-xom/test1.xml
far base uri=file:/home/hip/test-xom/test.xml
I think getBaseURI() on element "far" returning
"file:/home/hip/test-xom/test.xml"
after it has been remove from the first document, and retaining it after
append
to the second document is going to be very confusing. More confusing then just
internal clearing actualBaseURI on detachment like in 1.0d25.
Brad
-
[XOM-interest] XOM 1.0 alpha 1 is here,
Elliotte Rusty Harold, 06/08/2004
-
Re: [XOM-interest] XOM 1.0 alpha 1 is here,
Michael Abato, 06/08/2004
-
Re: [XOM-interest] XOM 1.0 alpha 1 is here,
Elliotte Rusty Harold, 06/09/2004
-
Message not available
- [XOM-interest] Multi ClassLoader environments, Elliotte Rusty Harold, 06/12/2004
-
Message not available
-
Re: [XOM-interest] XOM 1.0 alpha 1 is here,
Elliotte Rusty Harold, 06/09/2004
-
Re: [XOM-interest] XOM 1.0 alpha 1 is here,
Michael Abato, 06/08/2004
-
Re: [XOM-interest] XOM 1.0 alpha 1 is here,
Bradley S. Huffman, 06/08/2004
-
Re: [XOM-interest] XOM 1.0 alpha 1 is here,
Elliotte Harold - java FAQ, 06/08/2004
-
Re: [XOM-interest] XOM 1.0 alpha 1 is here,
Bradley S. Huffman, 06/09/2004
-
Re: [XOM-interest] XOM 1.0 alpha 1 is here,
Elliotte Rusty Harold, 06/09/2004
-
Re: [XOM-interest] XOM 1.0 alpha 1 is here,
Bradley S. Huffman, 06/09/2004
-
Re: [XOM-interest] XOM 1.0 alpha 1 is here,
Elliotte Rusty Harold, 06/09/2004
- Re: [XOM-interest] XOM 1.0 alpha 1 is here, Bradley S. Huffman, 06/10/2004
-
Re: [XOM-interest] XOM 1.0 alpha 1 is here,
Elliotte Rusty Harold, 06/09/2004
-
Re: [XOM-interest] XOM 1.0 alpha 1 is here,
Bradley S. Huffman, 06/09/2004
-
Re: [XOM-interest] XOM 1.0 alpha 1 is here,
Elliotte Rusty Harold, 06/09/2004
- Re: [XOM-interest] XOM 1.0 alpha 1 is here, Bradley S. Huffman, 06/09/2004
-
Re: [XOM-interest] XOM 1.0 alpha 1 is here,
Elliotte Rusty Harold, 06/09/2004
-
Re: [XOM-interest] XOM 1.0 alpha 1 is here,
Bradley S. Huffman, 06/09/2004
-
Re: [XOM-interest] XOM 1.0 alpha 1 is here,
Elliotte Harold - java FAQ, 06/08/2004
-
Re: [XOM-interest] XOM 1.0 alpha 1 is here,
jcowan, 06/08/2004
- Re: [XOM-interest] XOM 1.0 alpha 1 is here, Elliotte Harold - java FAQ, 06/08/2004
- <Possible follow-up(s)>
- Re: [XOM-interest] XOM 1.0 alpha 1 is here, Michael Abato, 06/10/2004
Archive powered by MHonArc 2.6.24.