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

Re: Zerces 1.4.2, JAXP, schema - can't validate (Answer)

  • From: Pete Sahm <psahm@u...>
  • To: XML Dev List <xml-dev@l...>
  • Date: Wed, 08 Aug 2001 11:13:08 -0400

pete sahm
I appear to have solved the problem (it was my fault) and wanted to post 
the follow-up for anyone searching the archives: the parser must be made 
namespace aware, as the XML schema definitions are in a namespace. So, 
adding the following line:

dbf.setNamespaceAware(true);

prior to obtaining the DocumentBuilder solves the problem.

Pete

At 8/6/2001 02:53 PM, Pete Sahm wrote:

>Hi,
>
>Has anyone been able to successfully perform a validating parse against a 
>schema using  Xerces 1.4.2, the JAXP, and Java 1.3.1?
>
>I've seen several posts regarding the subject that I have gone though, yet 
>none seem to enable me to perform a validating parse on the sample 
>documents that ship with Xerces: personal-schema.xml using personal.xsd 
>(or any other docs/schemas, for that matter).
>
>The following snippet is the code I am using, and no matter what I have 
>tried I keep getting parse errors: "Element type "xxx" must be declared."
>
>         Document doc = null;
>         System.setProperty("javax.xml.parsers.DocumentBuilderFactory",
> 
>"org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
>
>         DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
>         dbf.setValidating(true);
>         DocumentBuilder db = dbf.newDocumentBuilder();
>         db.setErrorHandler(this);
>         doc = db.parse(xmlFile);
>
>My CLASSPATH contains only the Xerces jar and directory containing the 
>class containing the above code.
>
>Any and all help is greatly appreciated.
>
>Thanks in advance,
>Pete
>
>
>
>------------------------------------------------------------------
>The xml-dev list is sponsored by XML.org <http://www.xml.org>, an 
>initiative of OASIS <http://www.oasis-open.org>
>
>The list archives are at http://lists.xml.org/archives/xml-dev/
>
>To unsubscribe from this elist send a message with the single word
>"unsubscribe" in the body to: xml-dev-request@l...


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.