xom-interest AT lists.ibiblio.org
Subject: XOM API for Processing XML with Java
List archive
Re: [XOM-interest] Preserve white space in text nodes
- From: Christophe Marchand <christophe.marchand AT axyus.com>
- To: XOM API for Processing XML with Java <xom-interest AT lists.ibiblio.org>
- Cc: "Stevenson, Todd \(GE Healthcare\)" <Todd.T.Stevenson AT ge.com>
- Subject: Re: [XOM-interest] Preserve white space in text nodes
- Date: Thu, 19 Jan 2012 08:35:57 +0100
This works correctly for me.
Best regards,
Christophe
Le 18/01/2012 23:33, Stevenson, Todd (GE Healthcare) a écrit :
This method:child.addAttribute(new Attribute("xml:space", XMLConstants.XML_NS_URI, "preserve"));
import nu.xom.Document;
import nu.xom.Element;
import nu.xom.Serializer;
void createXML() throws IOException {
Element root = new Element("Root");
Element child = new Element("Child");
child.appendChild("\n first line \n second
line\n");
root.appendChild(child);
Document doc = new Document(root);
Serializer serializer = new Serializer(System.out, "ISO-8859-1");
serializer.setIndent(4);
serializer.setMaxLength(100);
serializer.write(doc);
}
Generates this output:
<?xml version="1.0" encoding="ISO-8859-1"?>
<Root>
<Child> first line second line</Child>
</Root>
Note that it discards the extra white space and newline characters. I
want to be able to preserve this whitespace to the output XML document.
Thanks
-----Original Message-----
From: xom-interest-bounces AT lists.ibiblio.org
[mailto:xom-interest-bounces AT lists.ibiblio.org] On Behalf Of Elliotte Rusty
Harold
Sent: Wednesday, January 18, 2012 1:57 PM
To: XOM API for Processing XML with Java
Subject: Re: [XOM-interest] Preserve white space in text nodes
On Wed, Jan 18, 2012 at 2:06 PM, Stevenson, Todd (GE
Healthcare)<Todd.T.Stevenson AT ge.com> wrote:
I can't figure out how to preserve whitespace in a text node.Do you have code that demonstrates what's happening?
I use the serializer to write my output and it strips the spaces and newline
characters.
Is there a configuration option to make this work correctly?
--
Elliotte Rusty Harold
elharo AT ibiblio.org
_______________________________________________
XOM-interest mailing list
XOM-interest AT lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/xom-interest
_______________________________________________
XOM-interest mailing list
XOM-interest AT lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/xom-interest
-
[XOM-interest] Preserve white space in text nodes,
Stevenson, Todd (GE Healthcare), 01/18/2012
-
Re: [XOM-interest] Preserve white space in text nodes,
Elliotte Rusty Harold, 01/18/2012
-
Re: [XOM-interest] Preserve white space in text nodes,
Stevenson, Todd (GE Healthcare), 01/18/2012
-
Re: [XOM-interest] Preserve white space in text nodes,
Christophe Marchand, 01/19/2012
- Re: [XOM-interest] Preserve white space in text nodes, Christophe Marchand, 01/19/2012
-
Re: [XOM-interest] Preserve white space in text nodes,
Elliotte Rusty Harold, 01/19/2012
-
Re: [XOM-interest] Preserve white space in text nodes,
Michael Kay, 01/19/2012
- Re: [XOM-interest] Preserve white space in text nodes, Stevenson, Todd (GE Healthcare), 01/19/2012
- Re: [XOM-interest] Preserve white space in text nodes, Olivier Lefevre, 01/21/2012
-
Re: [XOM-interest] Preserve white space in text nodes,
Michael Kay, 01/19/2012
-
Re: [XOM-interest] Preserve white space in text nodes,
Christophe Marchand, 01/19/2012
-
Re: [XOM-interest] Preserve white space in text nodes,
Stevenson, Todd (GE Healthcare), 01/18/2012
-
Re: [XOM-interest] Preserve white space in text nodes,
Elliotte Rusty Harold, 01/18/2012
Archive powered by MHonArc 2.6.24.