Jens Kripl
2011-09-26 18:46:26 UTC
Hi all,
like me) for indenting, maybe something with the behavior is not
perfect.
So you asked for a test, here it is (hope that's the right for to
submit it):
(just add this test to "nu.xom.tests.SerializerTest")
public void testAttributeWithIndenting() throws IOException {
root.addAttribute(new Attribute("Name", "Hello Name"));
root.appendChild(new Element("sameline"));
ByteArrayOutputStream out = new ByteArrayOutputStream();
Serializer serializer = new Serializer(out, "UTF-8");
serializer.setIndent(4);
serializer.write(doc);
String result = out.toString("UTF-8");
assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"
+ "<root Name=\"Hello Name\">\r\n"
+ " <sameline/>\r\n"
+ "</root>\r\n", result);
}
Regards,
Jens
Am 16.09.2011 12:01:37 CEST
However if you tell XOM to change the white space by indenting, then
yes, it will change the white space. If you don't want XOM to change
the white space, don't use indenting.
Understood. But when people end up using DOM (or javax.xml.Transformeryes, it will change the white space. If you don't want XOM to change
the white space, don't use indenting.
like me) for indenting, maybe something with the behavior is not
perfect.
So you asked for a test, here it is (hope that's the right for to
submit it):
(just add this test to "nu.xom.tests.SerializerTest")
public void testAttributeWithIndenting() throws IOException {
root.addAttribute(new Attribute("Name", "Hello Name"));
root.appendChild(new Element("sameline"));
ByteArrayOutputStream out = new ByteArrayOutputStream();
Serializer serializer = new Serializer(out, "UTF-8");
serializer.setIndent(4);
serializer.write(doc);
String result = out.toString("UTF-8");
assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"
+ "<root Name=\"Hello Name\">\r\n"
+ " <sameline/>\r\n"
+ "</root>\r\n", result);
}
Regards,
Jens
Am 16.09.2011 12:01:37 CEST
Send XOM-interest mailing list submissions to
xom-interest at lists.ibiblio.org
To subscribe or unsubscribe via the World Wide Web, visit
http://lists.ibiblio.org/mailman/listinfo/xom-interest
or, via email, send a message with subject or body 'help' to
xom-interest-request at lists.ibiblio.org
You can reach the person managing the list at
xom-interest-owner at lists.ibiblio.org
When replying, please edit your Subject line so it is more specific
than "Re: Contents of XOM-interest digest..."
1. Re: [SPAM(hdr)] - Using Serializer with Indenting
(without alteringAttribute values) (Peter Taylor)
2. Re: [SPAM(hdr)] - Using Serializer with Indenting (without
alteringAttribute values) (Elliotte Rusty Harold)
3. Re: [SPAM(hdr)] - Using Serializer with Indenting
(without alteringAttribute values) (Leif Stainsby)
4. Re: [SPAM(hdr)] - Using Serializer with Indenting (without
alteringAttribute values) (Elliotte Rusty Harold)
----------------------------------------------------------------------
Message: 1
Date: Thu, 15 Sep 2011 17:25:16 +0100
From: "Peter Taylor" <peter.taylor at greenhat.com>
Subject: Re: [XOM-interest] [SPAM(hdr)] - Using Serializer with
Indenting (without alteringAttribute values)
To: "XOM API for Processing XML with Java"
<xom-interest at lists.ibiblio.org>
<1C8E52697A489F429275597D15DB3DE704E0AA34 at ghc-winsvr1.greenhat.local>
Content-Type: text/plain; charset="us-ascii"
Certiainly there never use to be. I ended up transforming the XOM to
DOM.
http://www.chipkillmar.net/2009/03/25/pretty-print-xml-from-a-dom/
-----Original Message-----
From: xom-interest-bounces at lists.ibiblio.org
[mailto:xom-interest-bounces at lists.ibiblio.org] On Behalf Of Jens
Kripl Sent: 15 August 2011 20:57
To: xom-interest at lists.ibiblio.org
Subject: [SPAM(hdr)] - [XOM-interest] Using Serializer with Indenting
(without alteringAttribute values)
Hi,
I'm using the Serializer to pretty print my XOM constructed XML.
I've read the javadoc and some comments on the list that it may change
Before : <foo name="Abc CdeF" />
After : <foo name="Abc CdeF" />
Expected: <foo name="Abc CdeF" />
Is there any way to change this behaviour? The value of the attribute
should not be changed, but elements should be indented.
Regards,
Jens
_______________________________________________
XOM-interest mailing list
XOM-interest at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/xom-interest
------------------------------
Message: 2
Date: Thu, 15 Sep 2011 18:40:42 -0400
From: Elliotte Rusty Harold <elharo at ibiblio.org>
Subject: Re: [XOM-interest] [SPAM(hdr)] - Using Serializer with
Indenting (without alteringAttribute values)
To: XOM API for Processing XML with Java
<xom-interest at lists.ibiblio.org>
<CAGhczrpd5CganUdtXNYJMSzFRkpuiWio12iP-yFbWSRL-1_MbQ at mail.gmail.com>
Content-Type: text/plain; charset=UTF-8
On Thu, Sep 15, 2011 at 12:25 PM, Peter Taylor
test case?
However if you tell XOM to change the white space by indenting, then
yes, it will change the white space. If you don't want XOM to change
the white space, don't use indenting.
xom-interest at lists.ibiblio.org
To subscribe or unsubscribe via the World Wide Web, visit
http://lists.ibiblio.org/mailman/listinfo/xom-interest
or, via email, send a message with subject or body 'help' to
xom-interest-request at lists.ibiblio.org
You can reach the person managing the list at
xom-interest-owner at lists.ibiblio.org
When replying, please edit your Subject line so it is more specific
than "Re: Contents of XOM-interest digest..."
1. Re: [SPAM(hdr)] - Using Serializer with Indenting
(without alteringAttribute values) (Peter Taylor)
2. Re: [SPAM(hdr)] - Using Serializer with Indenting (without
alteringAttribute values) (Elliotte Rusty Harold)
3. Re: [SPAM(hdr)] - Using Serializer with Indenting
(without alteringAttribute values) (Leif Stainsby)
4. Re: [SPAM(hdr)] - Using Serializer with Indenting (without
alteringAttribute values) (Elliotte Rusty Harold)
----------------------------------------------------------------------
Message: 1
Date: Thu, 15 Sep 2011 17:25:16 +0100
From: "Peter Taylor" <peter.taylor at greenhat.com>
Subject: Re: [XOM-interest] [SPAM(hdr)] - Using Serializer with
Indenting (without alteringAttribute values)
To: "XOM API for Processing XML with Java"
<xom-interest at lists.ibiblio.org>
<1C8E52697A489F429275597D15DB3DE704E0AA34 at ghc-winsvr1.greenhat.local>
Content-Type: text/plain; charset="us-ascii"
Certiainly there never use to be. I ended up transforming the XOM to
DOM.
http://www.chipkillmar.net/2009/03/25/pretty-print-xml-from-a-dom/
-----Original Message-----
From: xom-interest-bounces at lists.ibiblio.org
[mailto:xom-interest-bounces at lists.ibiblio.org] On Behalf Of Jens
Kripl Sent: 15 August 2011 20:57
To: xom-interest at lists.ibiblio.org
Subject: [SPAM(hdr)] - [XOM-interest] Using Serializer with Indenting
(without alteringAttribute values)
Hi,
I'm using the Serializer to pretty print my XOM constructed XML.
I've read the javadoc and some comments on the list that it may change
Before : <foo name="Abc CdeF" />
After : <foo name="Abc CdeF" />
Expected: <foo name="Abc CdeF" />
Is there any way to change this behaviour? The value of the attribute
should not be changed, but elements should be indented.
Regards,
Jens
_______________________________________________
XOM-interest mailing list
XOM-interest at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/xom-interest
------------------------------
Message: 2
Date: Thu, 15 Sep 2011 18:40:42 -0400
From: Elliotte Rusty Harold <elharo at ibiblio.org>
Subject: Re: [XOM-interest] [SPAM(hdr)] - Using Serializer with
Indenting (without alteringAttribute values)
To: XOM API for Processing XML with Java
<xom-interest at lists.ibiblio.org>
<CAGhczrpd5CganUdtXNYJMSzFRkpuiWio12iP-yFbWSRL-1_MbQ at mail.gmail.com>
Content-Type: text/plain; charset=UTF-8
On Thu, Sep 15, 2011 at 12:25 PM, Peter Taylor
Certiainly there never use to be. I ended up transforming the XOM to
DOM.
http://www.chipkillmar.net/2009/03/25/pretty-print-xml-from-a-dom/
-----Original Message-----
From: xom-interest-bounces at lists.ibiblio.org
[mailto:xom-interest-bounces at lists.ibiblio.org] On Behalf Of Jens
Kripl Sent: 15 August 2011 20:57
To: xom-interest at lists.ibiblio.org
Subject: [SPAM(hdr)] - [XOM-interest] Using Serializer with
Indenting (without alteringAttribute values)
Hi,
I'm using the Serializer to pretty print my XOM constructed XML.
I've read the javadoc and some comments on the list that it may
Before : <foo name="Abc CdeF" />
After : <foo name="Abc CdeF" />
Expected: <foo name="Abc CdeF" />
Is there any way to change this behaviour? The value of the
attribute should not be changed, but elements should be indented.
there are several things that could be happening here. Do you have aDOM.
http://www.chipkillmar.net/2009/03/25/pretty-print-xml-from-a-dom/
-----Original Message-----
From: xom-interest-bounces at lists.ibiblio.org
[mailto:xom-interest-bounces at lists.ibiblio.org] On Behalf Of Jens
Kripl Sent: 15 August 2011 20:57
To: xom-interest at lists.ibiblio.org
Subject: [SPAM(hdr)] - [XOM-interest] Using Serializer with
Indenting (without alteringAttribute values)
Hi,
I'm using the Serializer to pretty print my XOM constructed XML.
I've read the javadoc and some comments on the list that it may
Before : <foo name="Abc CdeF" />
After : <foo name="Abc CdeF" />
Expected: <foo name="Abc CdeF" />
Is there any way to change this behaviour? The value of the
attribute should not be changed, but elements should be indented.
test case?
However if you tell XOM to change the white space by indenting, then
yes, it will change the white space. If you don't want XOM to change
the white space, don't use indenting.