The Artima Developer Community
Sponsored Link

Java Answers Forum
How validate Schema with JAXP DOM?

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Dan Bizman

Posts: 2
Nickname: dbizman
Registered: Feb, 2003

How validate Schema with JAXP DOM? Posted: Mar 10, 2003 3:38 PM
Reply to this message Reply
Advertisement
I want to use the Java XML API so that I can pop in and out different
implementations of XML parsers as I need/want to. However, as far as I can
tell, if I want Xerces to validate an XML document with a Schema, I CANNOT
use the DocumentBuilderFactory method. Is this correct?

As far as I can tell, the only way to make it use a schema for validation
is by setting certain parser features such
as "http://apache.org/xml/features/validation/schema" and this can only be
done on either a SAX Parser or Xerces' DOMParser, which you MUST refer to
explicitly by name to use "setFeature" since setFeature is not part of the
DOM interface.

Does anyone know if there's a way around this? Can I actually use the
following and make it use an XML Schema for validation?


<code>
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setValidating( true );factory.setNamespaceAware( true );
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse( file );
</code>

If not, then what was the purpose of the above interface (JAXP)?!

Topic: Please somebody help me with this Previous Topic   Next Topic Topic: Heck of a problem, please help

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use