Hi again,

What is the best way to write a minimized version of a document that might contain namespaces?

In looking at the source of XMLWriter, it shows there is no faqcility to write namespaces the way I am trying to below. Now I am just writing to the servelt output stream, but perhaps the method below could be useful in the XMLWriter?

public void writeOpen(Element element, List namespaces) {
  writer.write("<");
  writer.write(element.getQualifiedName());
  for (int i=0; i < namespaces.size(); i++) {
    writeNamespace(namespaces.get(i));
  }
  writeAttributes(element);
}

is this worth it?

best,
-Rob


Robert Koberg wrote:
Hi,

I am trying to use the XMLWriter to send an XML stream to a browser (reduce from a much larger Document). The elements I want to write exist in a namespace. But everything I have tried so far will not create the namespace in the outputstream. If I use the XMLWriter to write the dom4j Document it works as expected. How can I get the namespace into the output?

Here is an example of what i have tried:

XMLWriter xmlWriter = new XMLWriter(out);
xmlWriter.startDocument();
xmlWriter.writeOpen(parentElem);
//xmlWriter.write(parentElem.getNamespace());
List<Element> children = parentElem.elements();
for (Element child : children) {
  xmlWriter.writeOpen(child);
  xmlWriter.writeClose(child);
}
xmlWriter.writeClose(parentElem);
xmlWriter.endDocument();
xmlWriter.close();

thanks,
-Rob




-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
dom4j-user mailing list
dom4j-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to