Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4916415

getBaseURI() returns null when base URI is defined

XMLWordPrintable

    • b30
    • generic
    • generic
    • Verified

        Name: eaR10174 Date: 09/03/2003


          The method Node.getBaseURI() returns null in case when the base URI is defined by the
        attribute 'xml:base' in a root element (see test.java below). According to the method
        javadoc
          
            public String getBaseURI()

            The absolute base URI of this node or null if undefined. This value is computed
            according to [XML Base].

        the method should return the defined uri.

          The bug appears in jdk1.5.0beta-b17 and affects a new JCK1.5 test:
          
            api/org_w3c/dom/Node/index.html#GetBaseURI

        ------------------------------------test.java-----------------------------
        import javax.xml.parsers.DocumentBuilderFactory;
        import javax.xml.parsers.DocumentBuilder;
        import org.xml.sax.InputSource;
        import org.w3c.dom.Document;
        import java.io.StringReader;

        public class test {

            String data =
                "<?xml version='1.0' ?>"
              + "<root xml:base='http://xxx.yyy/&#39; />";
              
            DocumentBuilder docBuilder = null;

            public static void main(String argv[]) {
                new test().run();
            }
            
            public void run() {
                try {
                    DocumentBuilderFactory docBF = DocumentBuilderFactory.newInstance();
                    docBuilder = docBF.newDocumentBuilder();
                    
                    Document doc = parse(data);
                    
                    System.out.println(doc.getDocumentElement().getBaseURI());
                    
                } catch (Exception e) {
                    e.printStackTrace();
                    return;
                }

            }
            
            private Document parse(String xmlData) throws Exception {
                 StringReader in = new StringReader(xmlData);
                 InputSource source = new InputSource(in);
                 return docBuilder.parse(source);
            }
        }
        --------------------------------------------------------------------------
        % java -showversion test
        java version "1.5.0-beta"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b17)
        Java HotSpot(TM) Client VM (build 1.5.0-beta-b17, mixed mode)

        null
        --------------------------------------------------------------------------

        ======================================================================

              nbajajsunw Neeraj Bajaj (Inactive)
              evgsunw Evg Evg (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: