  | Mailing List | | Home | | Forum Home | | JBoss - Java Application Server | | Tomcat - JSP/Servlet container | | Struts - A MVC web framework | | iText - An open source PDF Java Library | | JDOM - JDOM XML Parser | | JSP - A mailing list about Java Server Pages specification and reference | | J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition | | J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog | | Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology | |
Struts & Hibernate
|
|
|
  | | | Newlines between attributes | Newlines between attributes 2006-03-21 - By Michael Kay
Back No XML serializers that I know of give you this much control over the output. The Saxon serializer (which you could invoke to serialize the JDOM) will put long attributes on separate lines, but using its own algorithm, not yours. If you really want control at this level, you probably have to write your own serializer. Putting a newline as part of the attribute name is clearly doomed - you're lucky it got stripped off rather than being rejected as an invalid name character. Michael Kay http://www.saxonica.com/
__ __
From: jdom-interest-bounces@(protected) [mailto:jdom-interest-bounces@(protected)] On Behalf Of David Patterson Sent: 21 March 2006 18:09 To: jdom-interest@(protected) Subject: [Norton AntiSpam] [jdom-interest] Newlines between attributes
I'm using JDOM and like it very much for its ease of use.
I'm now using JDOM to create a series of XML files where the attribute values are long strings. As a result, after 2-3 of them, the element definition is very long. I know how to insert text objects between objects to force line breaks, but what I have been so far unable to do is to specify line breaks at known places between attributes in an element.
Is there a way to do this? Does it have to be done in a post-processing task?
I tried doing:
dmodule.setAttribute( "\nnoNamespaceSchemaLocation",
"procedSchema.xsd", ns );
...but JDOM removed the leading NL character from the attribute name.
Dave Patterson
dpatterson@(protected)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML xmlns="http://www.w3.org/TR/REC-html40" xmlns:o = "urn:schemas-microsoft-com:office:office" xmlns:w = "urn:schemas-microsoft-com:office:word"><HEAD> <META http-equiv=Content-Type content="text/html; charset=us-ascii"> <META content="MSHTML 6.00.2900.2802" name=GENERATOR> <STYLE>@(protected) Section1 {size: 8.5in 11.0in; margin: 1.0in 1.25in 1.0in 1.25in; } P.MsoNormal { FONT-SIZE: 12pt; MARGIN: 0in 0in 0pt; COLOR: black; FONT-FAMILY: Arial } LI.MsoNormal { FONT-SIZE: 12pt; MARGIN: 0in 0in 0pt; COLOR: black; FONT-FAMILY: Arial } DIV.MsoNormal { FONT-SIZE: 12pt; MARGIN: 0in 0in 0pt; COLOR: black; FONT-FAMILY: Arial } A:link { COLOR: blue; TEXT-DECORATION: underline } SPAN.MsoHyperlink { COLOR: blue; TEXT-DECORATION: underline } A:visited { COLOR: purple; TEXT-DECORATION: underline } SPAN.MsoHyperlinkFollowed { COLOR: purple; TEXT-DECORATION: underline } SPAN.EmailStyle17 { FONT-WEIGHT: normal; COLOR: windowtext; FONT-STYLE: normal; FONT-FAMILY: Arial ; TEXT-DECORATION: none; mso-style-type: personal-compose } DIV.Section1 { page: Section1 } </STYLE> </HEAD> <BODY lang=EN-US vLink=purple link=blue> <DIV dir=ltr align=left><SPAN class=276431719-21032006><FONT face=Arial color=#0000ff size=2>No XML serializers that I know of give you this much control over the output. The Saxon serializer (which you could invoke to serialize the JDOM) will put long attributes on separate lines, but using its own algorithm, not yours. If you really want control at this level, you probably have to write your own serializer.</FONT></SPAN></DIV> <DIV dir=ltr align=left><SPAN class=276431719-21032006><FONT face=Arial color=#0000ff size=2></FONT></SPAN> </DIV> <DIV dir=ltr align=left><SPAN class=276431719-21032006><FONT face=Arial color=#0000ff size=2>Putting a newline as part of the attribute name is clearly doomed - you're lucky it got stripped off rather than being rejected as an invalid name character.</FONT></SPAN></DIV> <DIV dir=ltr align=left><SPAN class=276431719-21032006><FONT face=Arial color=#0000ff size=2></FONT></SPAN> </DIV> <DIV dir=ltr align=left><SPAN class=276431719-21032006><FONT face=Arial color=#0000ff size=2>Michael Kay</FONT></SPAN></DIV> <DIV dir=ltr align=left><SPAN class=276431719-21032006><FONT face=Arial color=#0000ff size=2><A href="http://www.saxonica.com/">http://www.saxonica.com/</A></FONT></SPAN></DIV ><BR> <BLOCKQUOTE dir=ltr style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; MARGIN-RIGHT: 0px"> <DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left> <HR tabIndex=-1> <FONT face=Tahoma size=2><B>From:</B> jdom-interest-bounces@(protected) [mailto:jdom-interest-bounces@(protected)] <B>On Behalf Of </B>David Patterson<BR><B>Sent:</B> 21 March 2006 18:09<BR><B>To:</B> jdom-interest@(protected)<BR><B>Subject:</B> [Norton AntiSpam] [jdom-interest] Newlines between attributes<BR></FONT><BR></DIV> <DIV></DIV> <DIV class=Section1> <P class=MsoNormal><FONT face=Arial color=black size=2><SPAN style="FONT-SIZE: 10pt; COLOR: windowtext">I’m using JDOM and like it very much for its ease of use.<o:p></o:p></SPAN></FONT></P> <P class=MsoNormal><FONT face=Arial color=black size=2><SPAN style="FONT-SIZE: 10pt; COLOR: windowtext"><o:p> </o:p></SPAN></FONT></P> <P class=MsoNormal><FONT face=Arial color=black size=2><SPAN style="FONT-SIZE: 10pt; COLOR: windowtext">I’m now using JDOM to create a series of XML files where the attribute values are long strings. As a result, after 2-3 of them, the element definition is very long. I know how to insert text objects between objects to force line breaks, but what I have been so far unable to do is to specify line breaks at known places between attributes in an element.<o:p></o:p></SPAN></FONT></P> <P class=MsoNormal><FONT face=Arial color=black size=2><SPAN style="FONT-SIZE: 10pt; COLOR: windowtext"><o:p> </o:p></SPAN></FONT></P> <P class=MsoNormal><FONT face=Arial color=black size=2><SPAN style="FONT-SIZE: 10pt; COLOR: windowtext">Is there a way to do this? Does it have to be done in a post-processing task? <o:p></o:p></SPAN></FONT></P> <P class=MsoNormal><FONT face=Arial color=black size=2><SPAN style="FONT-SIZE: 10pt; COLOR: windowtext"><o:p> </o:p></SPAN></FONT></P> <P class=MsoNormal><FONT face=Arial color=black size=2><SPAN style="FONT-SIZE: 10pt; COLOR: windowtext">I tried doing:<o:p></o:p></SPAN></FONT></P> <P class=MsoNormal><FONT face=Arial color=black size=2><SPAN style="FONT-SIZE: 10pt; COLOR: windowtext"> dmodule.setAttribute( "\nnoNamespaceSchemaLocation", <o:p></o:p></SPAN></FONT></P> <P class=MsoNormal><FONT face=Arial color=black size=2><SPAN style="FONT-SIZE: 10pt; COLOR: windowtext"> "procedSchema.xsd", ns );<o:p></o:p></SPAN></FONT></P> <P class=MsoNormal><FONT face=Arial color=black size=2><SPAN style="FONT-SIZE: 10pt; COLOR: windowtext"><o:p> </o:p></SPAN></FONT></P> <P class=MsoNormal><FONT face=Arial color=black size=2><SPAN style="FONT-SIZE: 10pt; COLOR: windowtext"> ...but JDOM removed the leading NL character from the attribute name.<o:p></o:p></SPAN></FONT></P> <P class=MsoNormal><FONT face=Arial color=black size=2><SPAN style="FONT-SIZE: 10pt; COLOR: windowtext"><o:p> </o:p></SPAN></FONT></P> <DIV> <P class=MsoNormal><FONT face=Arial color=black size=2><SPAN style="FONT-SIZE: 10pt">Dave Patterson</SPAN></FONT><o:p></o:p></P> <P class=MsoNormal><EM><I><FONT face=Arial color=black size=2><SPAN style="FONT-SIZE: 10pt; FONT-STYLE: normal; FONT-FAMILY: Arial">dpatterson@(protected) -a-i.com</SPAN></FONT></I></EM><o:p></o:p></P></DIV> <P class=MsoNormal><FONT face=Arial color=black size=3><SPAN style="FONT-SIZE: 12pt"><o:p> </o:p></SPAN></FONT></P></DIV></BLOCKQUOTE ></BODY></HTML>
__ ____ ____ ____ ____ ____ ____ ____ ____ ____ To control your jdom-interest membership: http://www.jdom.org/mailman/options/jdom-interest/youraddr@(protected)
|
|
 |