Skip to main content



      Home
Home » Newcomers » Newcomers » Using Xerces 2.7 with J2SE 1.4.2
Using Xerces 2.7 with J2SE 1.4.2 [message #85842] Tue, 12 July 2005 23:13
Eclipse UserFriend
Originally posted by: anf4.cornell.edu

I apologize in advance if this is more of a Xerces question than an
Eclipse question. I am new to both.

I am currently using Eclipse 3.0 on Mac OS X 10.3. I am attempting to use
Xerces 2.7 to parse an XML document. How do I install Xerces and/or set
up Eclipse to use the JAXP 1.3 API provided by Xerces and not the J2SE
JAXP API, which is older?

Specifically, I am trying to run the following code:

</code>
public static void main(String args[]) {

try {

// Parse the XML Schema Document
SchemaFactory schemaFactory =
SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI );
Schema schema = schemaFactory.newSchema(new File("schema.xsd"));
System.out.println("Schema: " + schema);

// Set up the XML Parser
DocumentBuilderFactory documentBuilderFactory =
DocumentBuilderFactory.newInstance();
System.out.println("Factory: " + documentBuilderFactory);
documentBuilderFactory.setSchema(schema);
documentBuilderFactory.setValidating(true);
documentBuilderFactory.setNamespaceAware(true);

// Parse the XML Document
DocumentBuilder documentBuilder =
documentBuilderFactory.newDocumentBuilder();
System.out.println("Builder: " + documentBuilder);
documentBuilder.setErrorHandler(new ParserErrorHandler());
return documentBuilder.parse(new File("episodes.xml"));

} catch ....
}
</code>

The <code>System.out.println</code> calls print out:

<code>
Schema: org.apache.xerces.jaxp.validation.SimpleXMLSchema@a193fe
Factory: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl@517e5e
</code>

suggesting that Eclipse is using the Xerces implementation. However, when
it reaches the call to <code>setSchema</code>, it a
java.lang.NoSuchMethodError error is thrown. The <code>setSchema</code>
method was introduced in JAXP 1.3, which is present in Xerces but not in
the J2SE until version 5.0.

How can I force Eclipse to override the J2SE JAXP API?

Thanks for all of your help.

Regards,
Anthony Frasso
Previous Topic:drjava plugin + ecliipse 3.1
Next Topic:How do I install Eclipse
Goto Forum:
  


Current Time: Fri May 09 21:00:04 EDT 2025

Powered by FUDForum. Page generated in 0.10525 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top