It looks like a bug in the parser.

Changing lines 859 & 865 in Revision 1.86 of
org.apache.xerces.parsers.AbstractDOMParser as shown below should fix the 
problem.

public void xmlDecl(String version, String encoding, String standalone,
                        Augmentations augs)
        throws XNIException {
        if (!fDeferNodeExpansion) {
            // REVISIT: when DOM Level 3 is REC rely on Document.support
            //          instead of specific class
            if (fDocumentImpl != null) {
                fDocumentImpl.setVersion(version);
                fDocumentImpl.setEncoding(encoding);
-               fDocumentImpl.setStandalone("true".equals(standalone));
+               fDocumentImpl.setStandalone("yes".equals(standalone));
            }
        }
        else {
            fDeferredDocumentImpl.setVersion(version);
            fDeferredDocumentImpl.setEncoding(encoding);
-           fDeferredDocumentImpl.setStandalone("true".equals(standalone));
+           fDeferredDocumentImpl.setStandalone("yes".equals(standalone));
        }
    } // xmlDecl(String,String,String)

-----------------------------
Michael Glavassevich
[EMAIL PROTECTED]
4B Computer Engineering
University of Waterloo

On Sun, 11 May 2003, Pae Choi wrote:

> When I try to get the "standalone" attribute value from the DOM after loading
> the XML document from a file it *always* returns "false."
>
> I have a demo XML file containing two lines as:
>
> // ################ XML File ##################
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"/>
>
> And the code snippet is as follows:
>
> // ################ CODE SNIPPET ##################
> private void checkXMLDecl() {
>         // Create a factory object for creating DOM parsers
>         DocumentBuilderFactory  factory = 
> DocumentBuilderFactory.newInstance();
>         DocumentBuilder         builder = null;
>         Document                 xmlDOM = null;
>
>         try {
>             // Now use the factory to create a DOM parser
>             builder = factory.newDocumentBuilder();
>             xsDOM = builder.parse(xsdFile);
>
>             // Get the xml declaration
>             System.out.println("version = [" + 
> ((CoreDocumentImpl)xsDOM).getVersion() + "]");
>             System.out.println("encoding = [" + 
> ((CoreDocumentImpl)xsDOM).getEncoding() + "]");
>             // ########################################################
>             // The getStandalone() method does NOT work
>             if ( ((CoreDocumentImpl)xsDOM).getStandalone() )
>                 System.out.println("standalone is true");
>             else
>                 System.out.println("standalone is false");
>         }
>         catch (Exception ex) {
>         }
> }
>
> I have tested with Xerces v2.0.2, v2.2.1, and v2.4.0, but all three returns
> the same result, "false."
>
> Any comments?
>
>
> Pae
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to