[jdom-interest] The correct way to insert newlines and other
himank gupta
h_i_m_a_n_k at yahoo.com
Tue Sep 13 23:28:06 PDT 2005
Use root.addContent("\n");
instead of making newline a Text object.
Reason:
root.addContent(content1);
root.addContent(newline);
root.addContent(content2);
root.addContent(newline); // NOTE
the last action would give ILLEGAL ADD error on runtime because
newline is already a child of root
OR
root already has a child named newline.
Regards
Himank......
Element root = new Element("ROOT");
Text newline = new Text("");
Text content1 = new Text("");
Text content2 = new Text("");
content1.setText("test1");
newline.setText("\n"); //This seems kind of hackish
content2.setText("test2");
root.addContent(content1);
root.addContent(newline);
root.addContent(content2);
jdom-interest-request at jdom.org wrote:
Send jdom-interest mailing list submissions to
jdom-interest at jdom.org
To subscribe or unsubscribe via the World Wide Web, visit
http://www.jdom.org/mailman/listinfo/jdom-interest
or, via email, send a message with subject or body 'help' to
jdom-interest-request at jdom.org
You can reach the person managing the list at
jdom-interest-owner at jdom.org
When replying, please edit your Subject line so it is more specific
than "Re: Contents of jdom-interest digest..."
Today's Topics:
1. Re: & problems (Paul Libbrecht)
2. The correct way to insert newlines and other text codes into
JDOM elements (Kevin Chiu)
----------------------------------------------------------------------
Message: 1
Date: Mon, 12 Sep 2005 10:13:26 +0200
From: Paul Libbrecht
Subject: Re: [jdom-interest] & problems
To: Tatu Saloranta
Cc: jdom interest
Message-ID: <6270c84e7ae6a0f24a3b5d22db7740d1 at activemath.org>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Le 9 sept. 05, à 19:47, Tatu Saloranta a écrit :
> Does anyone know of xml processing package that does
> allow validation of the output? I have been thinking
> of writing such functionality into Woodstox, as it
> would seem potentially useful, but absence (?) of
> others doing that makes me wonder if it would be truly
> needed.
DTD-awareness would definitely help some output.
Our DTD is a mix of several DTDs and contains several implicit
attributes such as namespace declarations... I have proposed a patch to
XMLOutputter which uses a DTD-parser loaded DTD in order to avoid the
addition of these implicit attributes... our re-output sources are
suddenly readable again!
But I would more call this usage of DTD a "notation" usage instead of a
validation...
I wouldn't know how to validate the output of XMLOutputter except
reparse it!!
paul
------------------------------
Message: 2
Date: Mon, 12 Sep 2005 03:37:41 -0500
From: Kevin Chiu
Subject: [jdom-interest] The correct way to insert newlines and other
text codes into JDOM elements
To: jdom-interest at jdom.org
Message-ID: <1f32181a0509120137c240cf2 at mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1
Hello,
What's the correct way to add newlines (or other special characters)
to the text of a JDom element?
This is how I'm doing it now:
Element root = new Element("ROOT");
Text newline = new Text("");
Text content1 = new Text("");
Text content2 = new Text("");
content1.setText("test1");
newline.setText("\n"); //This seems kind of hackish
content2.setText("test2");
root.addContent(content1);
root.addContent(newline);
root.addContent(content2);
------------------------------
_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com
End of jdom-interest Digest, Vol 14, Issue 10
*********************************************
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.jdom.org/pipermail/jdom-interest/attachments/20050913/8da1b9f0/attachment.htm
More information about the jdom-interest
mailing list