Skip to Content.
Sympa Menu

xom-interest - [XOM-interest] confused by Namespaces

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Luca Passani <passani AT eunet.no>
  • To: xom-interest <xom-interest AT lists.ibiblio.org>
  • Subject: [XOM-interest] confused by Namespaces
  • Date: Tue, 24 May 2005 12:07:37 +0200


Hello, here is my big problem today.

I create new Elements using: (I add the namespace to avoid getting <br ns="" />

Element br = new Element("br", "http://www.w3.org/1999/xhtml";);

Then I create a new document:

public Document generateXHTML(String title_string) {

Element html = new Element("html");
Element head = new Element("head"); html.appendChild(head);
Element title = new Element("title");
head.appendChild(title);
Text title_node = new Text(title_string);
title.appendChild(title_node);
Element body = new Element("body");
html.appendChild(body);
Document doc = new Document(html);
DocType doctype
= new DocType("html","-//WAPFORUM//DTD XHTML Mobile 1.0//EN", "http://www.wapforum.org/DTD/xhtml-mobile10.dtd";);
doc.insertChild(doctype, 0);
return doc;
}

the problem is when I detach Elements from the other tree and I add to the new one I am creating. I get:

<img src="l_hp.gif" alt="bla bla" xmlns="http://www.w3.org/1999/xhtml"/>

what I want is:

<img src="l_hp.gif" alt="bla bla" >

If I try to create my Elements using the same namespace (i,.e.:

Element body = new Element("body", "http://www.w3.org/1999/xhtml";);

I get an IndexOutOfBound exception when I do:

part_body = part.getRootElement().getChildElements("body").get(0);

ideas?

Thank you

Luca






Archive powered by MHonArc 2.6.24.

Top of Page