[jdom-interest] Ampersand question

Gabor Greif gabor at no.netopia.com
Thu Jul 13 08:23:26 PDT 2000


On Thu, Jul 13, 2000 14:28 Uhr, Elliotte Rusty Harold
<mailto:elharo at metalab.unc.edu> wrote:
[lots of sensible stuff snipped]
>I worked on it some yesterday. I'll try to finish it up tomorrow. My 
>current thought is to create a new class called 
>org.jdom.output.XMLSerializer which has a whole bunch of serialize 
>methods that take JDOM objects and return strings; e.g.
>

I am coming back with a "patch" for my xml:space problem.
The SAXBuilder side seems to be fixed, but the XMLOutputter still mentions
xmlns:xml="..uri.." all the time.

I have applied the below modifications to my copy of XMLOutputter.java, and
would like to see it included in the CVS tree if appropriate.
Now that org.jdom.output.XMLSerializer will take over, it should probably
be included there. See my past thread having "xml:space" in its subject.

(at a convenient location)
    /**
     * <p>
     *  This will find out if the <code>{@link Namespace}</code>
     *    declaration has to be mentioned when outputting.
     * </p>
     *
     * @param ns <code>Namespace</code> to be examined in current context.
     * @param out <code>boolean</code> to be mentioned?
     */
    protected boolean needPrintNamespace(Namespace ns)
    {
    	if ((ns == Namespace.NO_NAMESPACE) || (namespaces.contains(ns)))
    		return false;
    	
    	// "xml..." (case insensitive) namespace is standard
    	if (ns.getPrefix().toLowerCase().startsWith("xml"))
    		return false;
    	
    	return true;
    }


And the two occurrences of this line

        if ((ns != Namespace.NO_NAMESPACE) && (!namespaces.contains(ns))) {

changed to

        if (needPrintNamespace(ns)) {


Cheers,

	Gabor






More information about the jdom-interest mailing list