[jdom-interest] Beta 9 RC1 (tiny namespace bug)

Rolf Lear rlear at algorithmics.com
Fri Apr 11 13:06:02 PDT 2003


It is sort of not a bug, but an absolute correctness.

Instead of using:
	Namespace xml = Namespace.getNamespace("xml", 
		"http://www.w3.org/XML/1998/namespace");	
	Element text = new Element("text");
	text.setAttribute("space", "preserve", xml);

use 

	text.setAttribute("space", "preserve", Namespace.XML_NAMESPACE);

Or, alternatively, check out setExpandEmptyElements(true) on XMLOutputter

Rolf

-----Original Message-----
From: Mike Brenner [mailto:mikeb at mitre.org]
Sent: Friday, April 11, 2003 3:55 PM
To: Jason Hunter; jdom-interest at jdom.org
Subject: Re: [jdom-interest] Beta 9 RC1 (tiny namespace bug)


Jason Hunter wrote:
> I just built and posted "JDOM 1.0 Beta 9 Release Candidate #1".
> Get it here: http://www.jdom.org/dist/binary


Hi Jason,

There may be a tiny bug, as described here.

When creating JDOM documents, one element at a time
in memory, we sometimes desire to have the following effect:

	<mytag> </mytag>

instead of the abbreviation:

	<mytag/>

That is, I desire an open and close tag with no text in between.

This is required, so that Javascript can add children to that node later,
in SVG graphics documents that are modified dynamically on the web.

One cannot achieve this effect by putting text composed of blanks,
non-breaking spaces (in either hex or html format), etc.

But one can achieve it, in JDOM b8, with the following command:

	Element text = new Element("text");
	text.setAttribute("xml:space", "preserve");

JDOM b8 did not require a namespace to be set for this to work.
In JDOM b9 the workaround is to use the following 

	Namespace xml = Namespace.getNamespace("xml", 
		"http://www.w3.org/XML/1998/namespace");	
	Element text = new Element("text");
	text.setAttribute("space", "preserve", xml);

THIS IS A BUG, BECAUSE the xml namespace is always 
supposed to be available in all xml tools.

But in JDOM b9, the following error message occurs, if the above b8 code is
used under b9:

org.jdom.IllegalNameException: 
The name "xml:space" is not legal for JDOM/XML attributes: 
Attribute names cannot contain colons.
 at org.jdom.Attribute.setName(Attribute.java:360)
 at org.jdom.Attribute.<init>(Attribute.java:228)
 at org.jdom.Attribute.<init>(Attribute.java:252)
 at org.jdom.Element.setAttribute(Element.java:1238
 at org.mitre.alloc.OutputSVG.createRowText(OutputSVG.java:5840)
...

_______________________________________________
To control your jdom-interest membership:
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhos
t.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://jdom.org/pipermail/jdom-interest/attachments/20030411/a283af7f/attachment.htm


More information about the jdom-interest mailing list