[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Help Needed on Parsing with DTD Using Xerces DOMParser

  • From: Allen Chang <allen@d...>
  • To: xml-dev@l...
  • Date: Tue, 26 Sep 2000 11:52:43 -0700

xerces domparser
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@d...
(408)938-4557


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.