OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Help Needed on Parsing with DTD Using Xerces DOMParser

[ Lists Home | Date Index | Thread Index ]
  • From: Allen Chang <allen@dejima.com>
  • To: xml-dev@lists.xml.org
  • Date: Tue, 26 Sep 2000 11:52:43 -0700

Hi,

I'm also new to XML and I need help on getting the value of my external DTD
from the DocType object after parsing.

My DTD looks like this:
    <!ELEMENT CASES (CASE+)>
    <!ELEMENT CASE (SCENARIO, CASENAME, PRIORITY, DESCRIPTIONHIDDEN,
        DESCRIPTION, PROMPT, BEFOREPIC, AFTERPIC, USER, ADMIN,
        INPUT, FUNCTIONALPOINT, COMPLEXITY, EXPECTED)>
    <!ELEMENT SCENARIO (#PCDATA)>
    ...

My xml file looks like this:
    <?xml version="1.0"?>
    <!DOCTYPE CASES SYSTEM "case.dtd">
    <CASES>
    <CASE>
    <SCENARIO>scenario 001</SCENARIO>
    <CASENAME>case 001</CASENAME>
    ...

And after parsing I print out the objects:
        try {
            parser.parse(xmlFile);
    DocumentType cases = parser.getDocument().getDoctype();
    System.out.println("cases.getName(): " + cases.getName());

    NamedNodeMap nnm = parser.getDocument().getDoctype().getEntities();
    System.out.println("nnm: " + nnm);
    System.out.println("nnm.getLength(): " + nnm.getLength());

    System.out.println("cases.getInternalSubset(): " +
cases.getInternalSubset());
    System.out.println("cases.getPublicId(): " + cases.getPublicId());
    System.out.println("cases.hasChildNodes(): " + cases.hasChildNodes());

    NodeList nodelist = cases.getChildNodes();
    System.out.println("nodelist: " + nodelist);
    System.out.println("nodelist.getLength(): " + nodelist.getLength());
    System.out.println("parser.getDoctype(): " +
parser.getDocument().getDoctype());
    System.out.println("parser.getNotations(): " +
parser.getDocument().getDoctype().getNotations());
    System.out.println("nodelist.getLength(): " + nodelist.getLength());

And this is the output:
    cases.getName(): CASES
    nnm: org.apache.xerces.dom.NamedNodeMapImpl@c8208cf6
    nnm.getLength(): 0
    cases.getInternalSubset(): null
    cases.getPublicId(): null
    cases.hasChildNodes(): false
    nodelist: [CASES: null]
    nodelist.getLength(): 0
    parser.getDoctype(): [CASES: null]
    parser.getNotations(): org.apache.xerces.dom.NamedNodeMapImpl@c8d88cf6
    nodelist.getLength(): 0

The only thing that's right is the name "CASES". Past experience told me
that "[CASES: null]" may not be really null.  I can't find enough
documentation from the DOMParser, nor much from the books. Could anybody
help me out? I'm spending long hours on this and it's frustrating. Thanks!

Allen Chang
Dejima, Inc.
allen@dejima.com
(408)938-4557





 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS