You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by bu...@apache.org on 2002/07/08 14:02:12 UTC

DO NOT REPLY [Bug 10549] New: - DOM3 normalizeDocument()

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10549>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10549

DOM3 normalizeDocument()

           Summary: DOM3 normalizeDocument()
           Product: Xerces2-J
           Version: 2.0.2
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: DOM
        AssignedTo: xerces-j-dev@xml.apache.org
        ReportedBy: jwt@arcor.de


In the following modified version of the DOM3 sample "DOM3.java", the call to 
normalizeDocument() throws this Exception :

[console output]

Parsing personal-schema.xml...
Normalizing document... 
Normalizing document after manipulation... 
java.lang.NullPointerException
	at org.apache.xerces.util.SymbolHash.get(SymbolHash.java:145)
	at org.apache.xerces.impl.xs.SchemaGrammar.getGlobalElementDecl
(SchemaGrammar.java:332)
	at 
org.apache.xerces.impl.xs.SubstitutionGroupHandler.getMatchingElemDecl
(SubstitutionGroupHandler.java:107)
	at org.apache.xerces.impl.xs.models.XSDFACM.oneTransition
(XSDFACM.java:299)
	at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement
(XMLSchemaValidator.java:1808)
	at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement
(XMLSchemaValidator.java:566)
	at org.apache.xerces.dom.DOMNormalizer.normalizeNode
(DOMNormalizer.java:319)
	at org.apache.xerces.dom.DOMNormalizer.normalizeNode
(DOMNormalizer.java:326)
	at org.apache.xerces.dom.DOMNormalizer.normalizeDocument
(DOMNormalizer.java:233)
	at org.apache.xerces.dom.CoreDocumentImpl.normalizeDocument
(CoreDocumentImpl.java:1062)
	at dom.DOM3.main(DOM3.java:86)














*** [modified DOM3.java] ***
.
.
.

    public static void main(String[] argv) {
        if (argv.length == 0) {
            printUsage();
            System.exit(1);
        }
        try {

            // get DOM Implementation using DOM Registry
            System.setProperty
(DOMImplementationRegistry.PROPERTY, "org.apache.xerces.dom.DOMImplementationSou
rceImpl");
            DOMImplementationLS impl =
                    (DOMImplementationLS) 
DOMImplementationRegistry.getDOMImplementation("LS-Load");

            // create DOMBuilder
            DOMBuilder builder = impl.createDOMBuilder
(DOMImplementationLS.MODE_SYNCHRONOUS, null);

            // create Error Handler
            DOMErrorHandler errorHandler = new DOM3();

            // set error handler
            builder.setErrorHandler(errorHandler);

            // set validation feature
            builder.setFeature("validate", true);

            // parse document
            System.out.println("Parsing " + argv[0] + "...");
            Document doc = builder.parseURI(argv[0]);


            org.apache.xerces.dom.DocumentImpl docImpl = 
(org.apache.xerces.dom.DocumentImpl) doc;

            // set error handler on the Document
            docImpl.setErrorHandler(errorHandler);

            // set validation feature
            docImpl.setNormalizationFeature("validate", true);

            // remove comments from the document
            docImpl.setNormalizationFeature("comments", false);

            System.out.println("Normalizing document... ");
            docImpl.normalizeDocument();

            // manipulate document
            Element root = (Element) doc.getDocumentElement();
/*
            DOMInputSource dis = impl.createDOMInputSource();
            String str = "<person 
id=\"VeryBig.Boss\"><name><family>Boss</family> 
<given>Big</given></name><email>chief@foo.com</email><link 
subordinates=\"one.worker two.worker three.worker four.worker 
five.worker\"/></person>";
            StringReader sr = new StringReader(str);
            dis.setCharacterStream(sr);
            builder.parseWithContext(dis, root, 
DOMBuilder.ACTION_APPEND_AS_CHILDREN);
*/

//            Comment elem = doc.createComment("comment A");
            Element elem = doc.createElement("person");
            elem.setAttribute("id", "Very.Big.Boss");
            root.appendChild(elem);
            System.out.println("Normalizing document after manipulation... ");
            docImpl.normalizeDocument();




            // create DOMWriter
            DOMWriter domWriter = impl.createDOMWriter();

            System.out.println("Serializing document... ");
            // serialize document to standard output
            domWriter.writeNode(System.out, doc);


        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
.
.
.

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org