You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mr...@apache.org on 2004/09/27 20:57:23 UTC

cvs commit: xml-xerces/java/docs faq-pcfp.xml

mrglavas    2004/09/27 11:57:23

  Modified:    java/docs faq-pcfp.xml
  Log:
  Update badly out of date FAQ on how to instruct the parser
  to validate against XML schema only. This has been possible
  for a long time with JAXP 1.2. Added some examples which
  demonstrate how to set the schema language property.
  
  Revision  Changes    Path
  1.9       +33 -4     xml-xerces/java/docs/faq-pcfp.xml
  
  Index: faq-pcfp.xml
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/docs/faq-pcfp.xml,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- faq-pcfp.xml	25 Feb 2004 16:22:44 -0000	1.8
  +++ faq-pcfp.xml	27 Sep 2004 18:57:23 -0000	1.9
  @@ -80,11 +80,40 @@
     <q>How can I tell the parser to validate against XML Schema and not to report DTD validation errors?</q>
     <a>
      <p>
  -     Currently this is impossible. We hope that JAXP 1.2 will provide this capability 
  -     via its schema language property. Otherwise, we might introduce a Xerces 
  -     language property that will allow specifying the language against which validation will occur.
  +    With JAXP 1.2 (or higher), you can instruct the parser to validate against XML Schema only. Using
  +    JAXP if the schema language property has been set to <code>http://www.w3.org/2001/XMLSchema</code>
  +    and the parser has been configured to validate then your documents will be validated against 
  +    XML Schema only, even if they have a DTD.
      </p>
  -   </a>
  +   <p>By doing the following you can configure a SAX parser to validate against XML Schema only:</p>
  +   <source>import javax.xml.parsers.SAXParser;
  +import javax.xml.parsers.SAXParserFactory;
  +
  +...
  +SAXParserFactory spf = SAXParserFactory.newInstance();
  +spf.setValidating(true);
  +spf.setNamespaceAware(true);
  +SAXParser parser = spf.newSAXParser();
  +parser.setProperty(
  +    "http://java.sun.com/xml/jaxp/properties/schemaLanguage",
  +    "http://www.w3.org/2001/XMLSchema");
  +...
  +</source>
  +   <p>For a DocumentBuilder this can be accomplished by doing the following:</p>
  +   <source>import javax.xml.parsers.DocumentBuilder;
  +import javax.xml.parsers.DocumentBuilderFactory;
  +
  +...
  +DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
  +dbf.setNamespaceAware(true);
  +dbf.setValidating(true);
  +dbf.setAttribute(
  +    "http://java.sun.com/xml/jaxp/properties/schemaLanguage",
  +    "http://www.w3.org/2001/XMLSchema");
  +DocumentBuilder docBuilder = dbf.newDocumentBuilder();
  +...
  +</source>
  +  </a>
    </faq>
   
   </faqs>
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org