You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by "Anthony N. Frasso" <af...@yahoo.com> on 2005/07/17 01:16:41 UTC
Trouble with setSchema Method
Hello, and thanks in advance for all of your help.
I am currently using Xerces (for Java) version 2.7 on Mac OS X 10.3.
Unfortunately, when I compile my java code, I get an error when
attempting to use the setSchema method of the DocumentBuilderFactory
class. What is going wrong?
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("playlist.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>
>From the command prompt, I attempt to compile the program:
<code>
javac -classpath
Library/resolver.jar:Library/xml-apis.jar:Library/xercesImpl.jar
Source/com/gafungi/SchmediaPlayer/PlaylistParser.java
Source/com/gafungi/SchmediaPlayer/PlaylistParserErrorHandler.java
<code>
Unfortunately, when I run this, I get the following error:
<code>
Source/com/gafungi/SchmediaPlayer/PlaylistParser.java:26:
cannot resolve symbol
symbol : method setSchema (javax.xml.validation.Schema)
location: class javax.xml.parsers.DocumentBuilderFactory
documentBuilderFactory.setSchema(schema);
</code>
Any and all help would be greatly appreciated!
Regards,
Anthony Frasso
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org
Re: Trouble with setSchema Method
Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Hi Anthony,
The setSchema() method was added to DocumentBuilderFactory in JAXP 1.3.
J2SE 1.4 contains an older version of JAXP (1.1) which doesn't have this
method. Simply putting xml-apis.jar on the classpath doesn't work because
the built-in libraries are always loaded first. Here are a couple FAQs
[1][2] which describe how you can make use of JAXP 1.3 with J2SE 1.4.
[1] https://jaxp.dev.java.net/Updating.html#java-14
[2] http://xml.apache.org/xerces2-j/faq-general.html#faq-4
"Anthony N. Frasso" <af...@yahoo.com> wrote on 07/16/2005 07:21:35 PM:
> > I am currently using Xerces (for Java) version 2.7 on Mac OS X 10.3.
>
> I should add this means I am using the J2SE 1.4.2.
>
> Regards,
> Anthony Frasso
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org
>
Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org
Re: Trouble with setSchema Method
Posted by "Anthony N. Frasso" <af...@yahoo.com>.
> I am currently using Xerces (for Java) version 2.7 on Mac OS X 10.3.
I should add this means I am using the J2SE 1.4.2.
Regards,
Anthony Frasso
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org