You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by le...@locus.apache.org on 2000/12/13 02:15:15 UTC

cvs commit: xml-xerces/java/src/org/apache/xerces/parsers XMLDocumentParser.java XMLParser.java

lehors      00/12/12 17:15:14

  Modified:    java/src/org/apache/xerces/impl Tag: xerces_j_2
                        Constants.java XMLDocumentScanner.java
               java/src/org/apache/xerces/parsers Tag: xerces_j_2
                        XMLDocumentParser.java XMLParser.java
  Log:
  implemented load-external-dtd feature
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.3   +5 -1      xml-xerces/java/src/org/apache/xerces/impl/Attic/Constants.java
  
  Index: Constants.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/Attic/Constants.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- Constants.java	2000/10/06 22:21:22	1.1.2.2
  +++ Constants.java	2000/12/13 01:15:08	1.1.2.3
  @@ -65,7 +65,7 @@
    *
    * @author Andy Clark, IBM
    *
  - * @version $Id: Constants.java,v 1.1.2.2 2000/10/06 22:21:22 andyc Exp $
  + * @version $Id: Constants.java,v 1.1.2.3 2000/12/13 01:15:08 lehors Exp $
    */
   public final class Constants {
   
  @@ -139,6 +139,9 @@
       /** Load dtd grammar when nonvalidating feature ("nonvalidating/load-dtd-grammar"). */
       public static final String LOAD_DTD_GRAMMAR_FEATURE = "nonvalidating/load-dtd-grammar";
   
  +    /** Load external dtd when nonvalidating feature ("nonvalidating/load-external-dtd"). */
  +    public static final String LOAD_EXTERNAL_DTD_FEATURE = "nonvalidating/load-external-dtd";
  +
       /** Defer node expansion feature ("dom/defer-node-expansion"). */
       //public static final String DEFER_NODE_EXPANSION_FEATURE = "dom/defer-node-expansion";
   
  @@ -230,6 +233,7 @@
           ALLOW_JAVA_ENCODINGS_FEATURE,
           CONTINUE_AFTER_FATAL_ERROR_FEATURE,
           LOAD_DTD_GRAMMAR_FEATURE,
  +        LOAD_EXTERNAL_DTD_FEATURE,
           //DEFER_NODE_EXPANSION_FEATURE,
           CREATE_ENTITY_REF_NODES_FEATURE,
           INCLUDE_IGNORABLE_WHITESPACE,
  
  
  
  1.1.2.77  +16 -2     xml-xerces/java/src/org/apache/xerces/impl/Attic/XMLDocumentScanner.java
  
  Index: XMLDocumentScanner.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/Attic/XMLDocumentScanner.java,v
  retrieving revision 1.1.2.76
  retrieving revision 1.1.2.77
  diff -u -r1.1.2.76 -r1.1.2.77
  --- XMLDocumentScanner.java	2000/11/30 01:27:55	1.1.2.76
  +++ XMLDocumentScanner.java	2000/12/13 01:15:09	1.1.2.77
  @@ -107,7 +107,7 @@
    * @author Arnaud  Le Hors, IBM
    * @author Eric Ye, IBM
    *
  - * @version $Id: XMLDocumentScanner.java,v 1.1.2.76 2000/11/30 01:27:55 ericye Exp $
  + * @version $Id: XMLDocumentScanner.java,v 1.1.2.77 2000/12/13 01:15:09 lehors Exp $
    */
   public class XMLDocumentScanner
       extends XMLScanner
  @@ -238,6 +238,8 @@
       /** Namespaces. */
       protected boolean fNamespaces;
   
  +    protected boolean fLoadExternalDTD = true;
  +
       // dispatchers
   
       /** Active dispatcher. */
  @@ -349,6 +351,9 @@
               Constants.XERCES_PROPERTY_PREFIX + Constants.GRAMMAR_POOL_PROPERTY;
           fGrammarPool = (GrammarPool)componentManager.getProperty(GRAMMAR_POOL);
   
  +        final String LOAD_EXTERNAL_DTD = Constants.XERCES_FEATURE_PREFIX + Constants.LOAD_EXTERNAL_DTD_FEATURE;
  +        fLoadExternalDTD = componentManager.getFeature(LOAD_EXTERNAL_DTD);
  +
           // initialize vars
           fMarkupDepth = 0;
           fCurrentElement = null;
  @@ -376,6 +381,15 @@
        */
       public void setFeature(String featureId, boolean state)
           throws SAXNotRecognizedException, SAXNotSupportedException {
  +
  +        // Xerces properties
  +        if (featureId.startsWith(Constants.XERCES_FEATURE_PREFIX)) {
  +            String feature = featureId.substring(Constants.XERCES_FEATURE_PREFIX.length());
  +            if (feature.equals(Constants.LOAD_EXTERNAL_DTD_FEATURE)) {
  +                fLoadExternalDTD = state;
  +            }
  +            return;
  +        }
       } // setFeature(String,boolean)
   
       /**
  @@ -658,7 +672,7 @@
           }
   
           // external subset
  -        if (systemId != null) {
  +        if (systemId != null && (fValidation || fLoadExternalDTD)) {
               XMLInputSource xmlInputSource = 
                   fEntityManager.resolveEntity(publicId, systemId, null);
               fEntityManager.setEntityHandler(fDTDScanner);
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.27  +7 -1      xml-xerces/java/src/org/apache/xerces/parsers/Attic/XMLDocumentParser.java
  
  Index: XMLDocumentParser.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/parsers/Attic/XMLDocumentParser.java,v
  retrieving revision 1.1.2.26
  retrieving revision 1.1.2.27
  diff -u -r1.1.2.26 -r1.1.2.27
  --- XMLDocumentParser.java	2000/10/26 18:32:18	1.1.2.26
  +++ XMLDocumentParser.java	2000/12/13 01:15:13	1.1.2.27
  @@ -92,7 +92,7 @@
    * @author Arnaud  Le Hors, IBM
    * @author Andy Clark, IBM
    *
  - * @version $Id: XMLDocumentParser.java,v 1.1.2.26 2000/10/26 18:32:18 andyc Exp $
  + * @version $Id: XMLDocumentParser.java,v 1.1.2.27 2000/12/13 01:15:13 lehors Exp $
    */
   public abstract class XMLDocumentParser
       extends XMLParser
  @@ -930,6 +930,12 @@
               // http://apache.org/xml/features/validation/nonvalidating/load-dtd-grammar
               //
               if (feature.equals(Constants.LOAD_DTD_GRAMMAR_FEATURE)) {
  +                return;
  +            }
  +            //
  +            // http://apache.org/xml/features/validation/nonvalidating/load-external-dtd
  +            //
  +            if (feature.equals(Constants.LOAD_EXTERNAL_DTD_FEATURE)) {
                   return;
               }
   
  
  
  
  1.1.2.17  +3 -1      xml-xerces/java/src/org/apache/xerces/parsers/Attic/XMLParser.java
  
  Index: XMLParser.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/parsers/Attic/XMLParser.java,v
  retrieving revision 1.1.2.16
  retrieving revision 1.1.2.17
  diff -u -r1.1.2.16 -r1.1.2.17
  --- XMLParser.java	2000/11/02 02:11:24	1.1.2.16
  +++ XMLParser.java	2000/12/13 01:15:13	1.1.2.17
  @@ -106,7 +106,7 @@
    * @author Arnaud  Le Hors, IBM
    * @author Andy Clark, IBM
    *
  - * @version $Id: XMLParser.java,v 1.1.2.16 2000/11/02 02:11:24 ericye Exp $
  + * @version $Id: XMLParser.java,v 1.1.2.17 2000/12/13 01:15:13 lehors Exp $
    */
   public abstract class XMLParser
       implements XMLComponentManager {
  @@ -178,6 +178,8 @@
           fFeatures.put(ALLOW_JAVA_ENCODINGS, Boolean.FALSE);
           final String CONTINUE_AFTER_FATAL_ERROR = Constants.XERCES_FEATURE_PREFIX + Constants.CONTINUE_AFTER_FATAL_ERROR_FEATURE;
           fFeatures.put(CONTINUE_AFTER_FATAL_ERROR, Boolean.FALSE);
  +        final String LOAD_EXTERNAL_DTD = Constants.XERCES_FEATURE_PREFIX + Constants.LOAD_EXTERNAL_DTD_FEATURE;
  +        fFeatures.put(LOAD_EXTERNAL_DTD, Boolean.TRUE);
   
           // create and register components
           fSymbolTable = symbolTable;
  
  
  

Re: Schema Validating SAXParser

Posted by Eric Ye <er...@locus.apache.org>.
You must have another jar file in your classpath that has DOM Level 1
implementation inside it.

As for the mailing list, please post your question at xerces-j-dev mailing
list next time (you need to subscribe to the list before you can post),
xerces-dev is almost deserted.
_____


Eric Ye * IBM, JTC - Silicon Valley * ericye@locus.apache.org

----- Original Message -----
From: "Vijayanand" <vi...@calsoft.co.in>
To: <xe...@xml.apache.org>
Sent: Tuesday, December 12, 2000 11:00 PM
Subject: Schema Validating SAXParser


> Hi,
>     I am  new to this group.I hope I may get the solution here..My Query
> is..
> "How to set features or properties for the SAXParser to validate XML with
> XML Schema.."
> Can any one have idea regarding this....I am badly in need of this..I
tried
> it by setting the Features of
>  "parser.setFeature("http://xml.org/sax/features/validation",true);
>   parser.setFeature("http://xml.org/sax/features/namespaces",true);
>
>
parser.setFeature("http://apache.org/xml/features/validation/schema",true);"
>
> Its working fine with DTD..But with Schema,while parsing...it simply shows
> the error like this..
>
> --------------------------------------------------------------------------
--
> Exception in thread "main" java.lang.NoSuchMethodError
>         at
> org.apache.xerces.parsers.DOMParser.startElement(DOMParser.java:1039)
>         at
>
org.apache.xerces.validators.common.XMLValidator.callStartElement(XMLValidat
> or.java:823)
>         at
>
org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XM
> LDocumentScanner.java:989)
>         at
>
org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.
> java:380)
>         at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:900)
>         at
>
org.apache.xerces.validators.common.XMLValidator.resolveSchemaGrammar(XMLVal
> idator.java:2198)
>         at
>
org.apache.xerces.validators.common.XMLValidator.bindNamespacesToElementAndA
> ttributes(XMLValidator.java:2086)
>         at
>
org.apache.xerces.validators.common.XMLValidator.callStartElement(XMLValidat
> or.java:815)
>         at
>
org.apache.xerces.framework.XMLDocumentScanner.scanElement(XMLDocumentScanne
> r.java:1852)
>         at
>
org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XM
> LDocumentScanner.java:1000)
>         at
>
org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.
> java:380)
>         at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:900)
>         at XercesCore.main(XercesCore.java:40)
> --------------------------------------------------------------------------
--
> ----
>
> I will be thankful,if anyone suggest me some idea..Thanx in advance....
>
> Regards,
> Vijay.
>
>
>
>
>
>
>
>
>


Schema Validating SAXParser

Posted by Vijayanand <vi...@calsoft.co.in>.
Hi,
    I am  new to this group.I hope I may get the solution here..My Query
is..
"How to set features or properties for the SAXParser to validate XML with
XML Schema.."
Can any one have idea regarding this....I am badly in need of this..I tried
it by setting the Features of
 "parser.setFeature("http://xml.org/sax/features/validation",true);
  parser.setFeature("http://xml.org/sax/features/namespaces",true);

parser.setFeature("http://apache.org/xml/features/validation/schema",true);"

Its working fine with DTD..But with Schema,while parsing...it simply shows
the error like this..

----------------------------------------------------------------------------
Exception in thread "main" java.lang.NoSuchMethodError
        at
org.apache.xerces.parsers.DOMParser.startElement(DOMParser.java:1039)
        at
org.apache.xerces.validators.common.XMLValidator.callStartElement(XMLValidat
or.java:823)
        at
org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XM
LDocumentScanner.java:989)
        at
org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.
java:380)
        at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:900)
        at
org.apache.xerces.validators.common.XMLValidator.resolveSchemaGrammar(XMLVal
idator.java:2198)
        at
org.apache.xerces.validators.common.XMLValidator.bindNamespacesToElementAndA
ttributes(XMLValidator.java:2086)
        at
org.apache.xerces.validators.common.XMLValidator.callStartElement(XMLValidat
or.java:815)
        at
org.apache.xerces.framework.XMLDocumentScanner.scanElement(XMLDocumentScanne
r.java:1852)
        at
org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XM
LDocumentScanner.java:1000)
        at
org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.
java:380)
        at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:900)
        at XercesCore.main(XercesCore.java:40)
----------------------------------------------------------------------------
----

I will be thankful,if anyone suggest me some idea..Thanx in advance....

Regards,
Vijay.