<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2655.35">
<TITLE>RE: [jdom-interest] Beta 9 RC1 (tiny namespace bug)</TITLE>
</HEAD>
<BODY>
<P><FONT SIZE=2>It is sort of not a bug, but an absolute correctness.</FONT>
</P>
<P><FONT SIZE=2>Instead of using:</FONT>
<BR> <FONT SIZE=2>Namespace xml = Namespace.getNamespace("xml", </FONT>
<BR> <FONT SIZE=2>"<A HREF="http://www.w3.org/XML/1998/namespace" TARGET="_blank">http://www.w3.org/XML/1998/namespace</A>"); </FONT>
<BR> <FONT SIZE=2>Element text = new Element("text");</FONT>
<BR> <FONT SIZE=2>text.setAttribute("space", "preserve", xml);</FONT>
</P>
<P><FONT SIZE=2>use </FONT>
</P>
<P> <FONT SIZE=2>text.setAttribute("space", "preserve", Namespace.XML_NAMESPACE);</FONT>
</P>
<P><FONT SIZE=2>Or, alternatively, check out setExpandEmptyElements(true) on XMLOutputter</FONT>
</P>
<P><FONT SIZE=2>Rolf</FONT>
</P>
<P><FONT SIZE=2>-----Original Message-----</FONT>
<BR><FONT SIZE=2>From: Mike Brenner [<A HREF="mailto:mikeb@mitre.org">mailto:mikeb@mitre.org</A>]</FONT>
<BR><FONT SIZE=2>Sent: Friday, April 11, 2003 3:55 PM</FONT>
<BR><FONT SIZE=2>To: Jason Hunter; jdom-interest@jdom.org</FONT>
<BR><FONT SIZE=2>Subject: Re: [jdom-interest] Beta 9 RC1 (tiny namespace bug)</FONT>
</P>
<BR>
<P><FONT SIZE=2>Jason Hunter wrote:</FONT>
<BR><FONT SIZE=2>> I just built and posted "JDOM 1.0 Beta 9 Release Candidate #1".</FONT>
<BR><FONT SIZE=2>> Get it here: <A HREF="http://www.jdom.org/dist/binary" TARGET="_blank">http://www.jdom.org/dist/binary</A></FONT>
</P>
<BR>
<P><FONT SIZE=2>Hi Jason,</FONT>
</P>
<P><FONT SIZE=2>There may be a tiny bug, as described here.</FONT>
</P>
<P><FONT SIZE=2>When creating JDOM documents, one element at a time</FONT>
<BR><FONT SIZE=2>in memory, we sometimes desire to have the following effect:</FONT>
</P>
<P> <FONT SIZE=2><mytag> </mytag></FONT>
</P>
<P><FONT SIZE=2>instead of the abbreviation:</FONT>
</P>
<P> <FONT SIZE=2><mytag/></FONT>
</P>
<P><FONT SIZE=2>That is, I desire an open and close tag with no text in between.</FONT>
</P>
<P><FONT SIZE=2>This is required, so that Javascript can add children to that node later,</FONT>
<BR><FONT SIZE=2>in SVG graphics documents that are modified dynamically on the web.</FONT>
</P>
<P><FONT SIZE=2>One cannot achieve this effect by putting text composed of blanks,</FONT>
<BR><FONT SIZE=2>non-breaking spaces (in either hex or html format), etc.</FONT>
</P>
<P><FONT SIZE=2>But one can achieve it, in JDOM b8, with the following command:</FONT>
</P>
<P> <FONT SIZE=2>Element text = new Element("text");</FONT>
<BR> <FONT SIZE=2>text.setAttribute("xml:space", "preserve");</FONT>
</P>
<P><FONT SIZE=2>JDOM b8 did not require a namespace to be set for this to work.</FONT>
<BR><FONT SIZE=2>In JDOM b9 the workaround is to use the following </FONT>
</P>
<P> <FONT SIZE=2>Namespace xml = Namespace.getNamespace("xml", </FONT>
<BR> <FONT SIZE=2>"<A HREF="http://www.w3.org/XML/1998/namespace" TARGET="_blank">http://www.w3.org/XML/1998/namespace</A>"); </FONT>
<BR> <FONT SIZE=2>Element text = new Element("text");</FONT>
<BR> <FONT SIZE=2>text.setAttribute("space", "preserve", xml);</FONT>
</P>
<P><FONT SIZE=2>THIS IS A BUG, BECAUSE the xml namespace is always </FONT>
<BR><FONT SIZE=2>supposed to be available in all xml tools.</FONT>
</P>
<P><FONT SIZE=2>But in JDOM b9, the following error message occurs, if the above b8 code is used under b9:</FONT>
</P>
<P><FONT SIZE=2>org.jdom.IllegalNameException: </FONT>
<BR><FONT SIZE=2>The name "xml:space" is not legal for JDOM/XML attributes: </FONT>
<BR><FONT SIZE=2>Attribute names cannot contain colons.</FONT>
<BR><FONT SIZE=2> at org.jdom.Attribute.setName(Attribute.java:360)</FONT>
<BR><FONT SIZE=2> at org.jdom.Attribute.<init>(Attribute.java:228)</FONT>
<BR><FONT SIZE=2> at org.jdom.Attribute.<init>(Attribute.java:252)</FONT>
<BR><FONT SIZE=2> at org.jdom.Element.setAttribute(Element.java:1238</FONT>
<BR><FONT SIZE=2> at org.mitre.alloc.OutputSVG.createRowText(OutputSVG.java:5840)</FONT>
<BR><FONT SIZE=2>...</FONT>
</P>
<P><FONT SIZE=2>_______________________________________________</FONT>
<BR><FONT SIZE=2>To control your jdom-interest membership:</FONT>
<BR><FONT SIZE=2><A HREF="http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com" TARGET="_blank">http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com</A></FONT>
</P>
</BODY>
</HTML>