[jdom-interest] Bug and query

Eric VERGNAUD eric.vergnaud at jlynx.com
Mon Jun 23 05:23:46 PDT 2003


Hi,

I'm new to this list, so first I would like to congratulate and thanks the
people involved in the creation of jdom, which is exactly what I've been
waiting for to start working with xml.

Haviong said that, I have 2 questions:

 - is this the place to file a bug ? If so, here is one:
    in XmlOutputter.java, there is come inconsistency in the way
    printElement, printElementNamespace, and printNamespace work together.
    This sometimes leads to the following production:
    
    <tag xmlns:'mynamesapce'>
        <childtag xmlns:>
        some data
        </childtag>
    </tag>

    This happens when you set the namespace for an element, but not for one
of its child element.
    This can be fixed by changing the code for printElementNamespace by the
following:
        Namespace ns = element.getNamespace();
        if (ns != Namespace.XML_NAMESPACE && ns != Namespace.NO_NAMESPACE)
        {
            printNamespace(ns, out, namespaces);
        }

 - is this the place to discuss some implementation choices ? If so, I am
not convinced by the following:

 in XmlOutputter.java, the 'output' method ends by the following code:
  
    // Output final line separator
    // We output this no matter what the newline flags say
    out.write(currentFormat.lineSeparator);

    out.flush();

Is writing a line separator at the end of the Xml stream mandatory ? I don't
know the answer, but I guess it's no, so I think it should be caller's
responsability to add this newline, because while this newline maybe fine in
a xml file, it may not be fine at all in a wireless xml stream, when the
other end is expecting a perfectly-formed (not just well-formed) document.
In fact I've met the situation where this newline would cause the other end
parser to fail at some point, and got stuck because I do not have access to
that parser which resides compiled on a mobile device.

So I would very much prefer:
 
    // Output final line separator
    // We output this no matter what the newline flags say
    newline(out);

    out.flush();

What do you think ?

-------------------------------
Eric VERGNAUD - JLynx Software
Cutting-edge technologies and
services for software companies
web: http://www.jlynx.com
-------------------------------




More information about the jdom-interest mailing list