Basic DOM parsing question

Arathi Arjun <[email protected]> Tue, 28 Oct 2003 22:41:20 -0500
Newsgroups gmane.text.xml.sax.general
Message-ID <[email protected]>
In the following basic code I get java.lang.Noclassdef Error
for: org/w3c/dom/ranges/DocumentRange

It blows up at the line DOMParser parser = new DOMParser();

___________________________________________________________
import org.apache.xerces.parsers.DOMParser;
//import org.apache.xerces.framework.*;
import org.w3c.dom.*;
import org.xml.sax.*;
import java.io.IOException;


public class XercesChecker {

  public static void main(String[] args) {
     
    if (args.length <= 0) {
      System.out.println("Usage: java XercesChecker URL"); 
      return;
    }
    String document = args[0];
    
    DOMParser parser = new DOMParser();
    try {
      parser.parse(document); 
      System.out.println(document + " is well-formed.");
    }
    catch (SAXException e) {
      System.out.println(document + " is not well-formed.");
    }
    catch (IOException e) { 
      System.out.println(
       "Due to an IOException, the parser could not check " 
       + document
      ); 
    }
   
  }

}


Any idea why this is happening. I have xerces.jar in my
classpath

Arathi



________________________________________________
Get your own "800" number
Voicemail, fax, email, and a lot more
http://www.ureach.com/reg/tag


---- On Fri, 24 Oct 2003, [email protected] ([email protected])
wrote:

> Well, if you're catching specific *single* elements,
startElements will work
> fine. When you talk about processing trees, I prefer to
introduce a XSL
> stylesheet where I make a specific template that recognizes
the automobile
> element.  Really, you could make a template for each kind of
vehicle.   I
> think it would be something like this: 
> 
> <?xml version="1.0" encoding="UTF-8" ?>
> <xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> version="1.0">
> 	<xsl:template match="//automobile/*/>
> 		Car Model:<xsl:value-of select="."/>
> 		Options:
> 		<xsl:for-each select="options/option"><xsl:value-of
> select="."/></xsl:for-each>
> 	</xsl:template>
> </xsl:stylesheet>
> 
> 
> > That helps. Also If I want to parse and output automobile
and
> > all its child elements and ignore ship and truck, is there
an
> > easy way to do it other than checking explicitly for
> > localName.equals("options") and
localName.equals("option")like
> > in the code below the xml file.
> > 
> >  <?xml-stylesheet href="mystyle.css" type="text/css"?>
> > > > <dealership>
> > > > <automobile make="Buick" model="Century" color="blue">
> > > > <options>
> > > > <option>convertible</option>
> > > > <option>CD Player</option>
> > > > </options>
> > > > </automobile>
> > > > <ship make="sailboat" color="red">
> > > > </ship>
> >      <truck color="blue">
> >      </truck>
> > > > </dealership>
> 
> 
> 



-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?   SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/
_______________________________________________
List: [email protected]
See:  http://www.saxproject.org
https://lists.sourceforge.net/lists/listinfo/sax-users