Message:

   The following issue has been closed.

   Resolver: nddelima
       Date: Tue, 21 Sep 2004 2:52 PM

Closing this, please re-open if the problem still exists.
---------------------------------------------------------------------
View the issue:
  http://issues.apache.org/jira/browse/XERCESJ-929

Here is an overview of the issue:
---------------------------------------------------------------------
        Key: XERCESJ-929
    Summary: getElementById does not work
       Type: Bug

     Status: Closed
 Resolution: CANNOT REPRODUCE

    Project: Xerces2-J
 Components: 
             DOM
   Versions:
             2.6.2

   Assignee: 
   Reporter: Nils Kilden-Pedersen

    Created: Thu, 25 Mar 2004 7:01 PM
    Updated: Tue, 21 Sep 2004 2:52 PM
Environment: Operating System: Windows NT/2K
Platform: PC

Description:
Using this schema:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
elementFormDefault="qualified" attributeFormDefault="unqualified">
        <xs:element name="root">
                <xs:annotation>
                        <xs:documentation>Comment describing your root 
element</xs:documentation>
                </xs:annotation>
                <xs:complexType>
                        <xs:sequence>
                                <xs:element name="someElement" type="IdentityType" 
maxOccurs="unbounded"/>
                        </xs:sequence>
                </xs:complexType>
        </xs:element>
        <xs:complexType name="IdentityType">
                <xs:sequence>
                        <xs:element name="someOtherElement" type="xs:string"/>
                </xs:sequence>
                <xs:attribute name="id" type="xs:ID" use="required"/>
        </xs:complexType>
</xs:schema>


And this XML file:

<?xml version="1.0" encoding="UTF-8"?>
<root>
        <someElement id="id1">
                <someOtherElement> Text 1</someOtherElement>
        </someElement>
        <someElement id="id2">
                <someOtherElement> Text 2</someOtherElement>
        </someElement>
        <someElement id="id3">
                <someOtherElement> Text 3</someOtherElement>
        </someElement>
        <someElement id="id4">
                <someOtherElement> Text 4</someOtherElement>
        </someElement>
        <someElement id="id5">
                <someOtherElement> Text 5</someOtherElement>
        </someElement>
</root>

I get null on getElementById. This class demonstrates the problem:
public class TestXercesId {
        private DocumentBuilder builder = null;
        
        public static void main(String[] args) {
                URL schema = TestXercesId.class.getResource("/test-xerces.xsd");
                TestXercesId test = new TestXercesId(schema);
                InputStream xml = 
test.getClass().getResourceAsStream("/test-xerces.xml");
                Document doc = test.parse(xml);
                Element id3 = doc.getElementById("id3");
                System.out.println("id3: " + id3);
        }
        
        private TestXercesId(URL schemaURL) {
                DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                factory.setAttribute(
                                "http://apache.org/xml/features/validation/dynamic";,
                                Boolean.TRUE);
                factory.setAttribute(
                                "http://apache.org/xml/features/validation/schema";,
                                Boolean.TRUE);
                factory.setAttribute(
                                
"http://apache.org/xml/features/validation/schema-full-checking";,
                                Boolean.TRUE);
                factory.setAttribute(
                                
"http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation";,
                                schemaURL.toExternalForm());
                try {
                        builder = factory.newDocumentBuilder();
                } catch (ParserConfigurationException e) {
                        throw new RuntimeException(e);
                }
        }

        private Document parse(InputStream xmlDocument) {
                try {
                        return builder.parse(xmlDocument);
                } catch (Exception e) {
                        throw new RuntimeException(e);
                } 
        }
}


---------------------------------------------------------------------
JIRA INFORMATION:
This message is automatically generated by JIRA.

If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa

If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


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

Reply via email to