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 "Hannaford.Michael" <Mi...@ftb.ca.gov> on 2005/12/05 21:29:12 UTC

question about validation feature in xerces 2.7.1

Hello Xerces gurus,

I am trying to enable the feature
http://apache.org/xml/features/validation/warn-on-undeclared-elemdef
using xerces 2.7.1, which I just downloaded from
http://www.wmwweb.com/apache/xml/xerces-j/. 

This is my java class:

import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

import org.xml.sax.SAXNotRecognizedException;

public class TestSAXParser
{
    //~ Methods
----------------------------------------------------------------

    public static void main( String[] args )
    {
        try
        {
            SAXParserFactory factory = SAXParserFactory.newInstance(  );
            factory.setFeature( VALIDATE_XML_FEATURE, true );
            factory.setFeature( WARN_ON_UNDECLARED_ELEMENT, true );
            factory.setFeature( WARN_ON_DUPICATE_ENTITY, true );
            
            SAXParser parser = factory.newSAXParser();
        }
        catch ( SAXNotRecognizedException snre )
        {
            System.out.println( "feature not supported: " +
snre.getMessage() );
            snre.printStackTrace();
        }
        catch ( Exception other )
        {
            other.printStackTrace();
        }
    }

    //~ Static variables
-------------------------------------------------------

    private static final String VALIDATE_XML_FEATURE =
        "http://xml.org/sax/features/validation";
    private static final String WARN_ON_UNDECLARED_ELEMENT =
 
"http://apache.org/xml/features/validation/warn-on-undeclared-elemdef";
    private static final String WARN_ON_DUPICATE_ENTITY =
        "http://apache.org/xml/features/warn-on-duplicate-entitydef";
}

When I run the code, however, I get this error:

C:\Documents and Settings\mhannaford\Desktop\test>java -classpath .
TestSAXParser
feature not supported: Feature
'http://apache.org/xml/features/validation/warn-on-undeclared-elemdef'
is not recognized.
org.xml.sax.SAXNotRecognizedException: Feature
'http://apache.org/xml/features/validation/warn-on-undeclared-elemdef'
is not recognized.
        at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.setFeature(
Unknown Source)
        at
com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.setFeatures(Unknow
n Source)
        at
com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.init(Unknown
Source)
        at
com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.<init>(Unknown
Source)
        at
com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl.newSAXParse
rImpl(Unknown Source)
        at
com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl.setFeature(
Unknown Source)
        at TestSAXParser.main(TestSAXParser.java:22)

Is there something obvious I am doing wrong, or is the feature not
enabled in this version of Xerces?

Thanks for your help.

--
Michael Hannaford
State of California
Child Support Enforcement project
916-290-8993

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


Re: question about validation feature in xerces 2.7.1

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Hello Michael,

It's a long standing bug [1] and has been broken for so long I'm not sure 
any version of Xerces 2.x ever supported the feature. It's been on my TODO 
list for awhile and I'm hoping to finally get around to it for Xerces 
2.8.0.

By the way you weren't actually using Xerces 2.7.1 when you ran your test 
(probably since you didn't put the Xerces jars on the classpath). The 
com.sun.org.apache.xerces.internal.* packages originate from Sun's Java 
5.0.

Thanks.

[1] http://issues.apache.org/jira/browse/XERCESJ-506

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

"Hannaford.Michael" <Mi...@ftb.ca.gov> wrote on 12/05/2005 
03:29:12 PM:

> Hello Xerces gurus,
> 
> I am trying to enable the feature
> http://apache.org/xml/features/validation/warn-on-undeclared-elemdef
> using xerces 2.7.1, which I just downloaded from
> http://www.wmwweb.com/apache/xml/xerces-j/. 
> 
> This is my java class:
> 
> import javax.xml.parsers.SAXParser;
> import javax.xml.parsers.SAXParserFactory;
> 
> import org.xml.sax.SAXNotRecognizedException;
> 
> public class TestSAXParser
> {
>     //~ Methods
> ----------------------------------------------------------------
> 
>     public static void main( String[] args )
>     {
>         try
>         {
>             SAXParserFactory factory = SAXParserFactory.newInstance(  );
>             factory.setFeature( VALIDATE_XML_FEATURE, true );
>             factory.setFeature( WARN_ON_UNDECLARED_ELEMENT, true );
>             factory.setFeature( WARN_ON_DUPICATE_ENTITY, true );
> 
>             SAXParser parser = factory.newSAXParser();
>         }
>         catch ( SAXNotRecognizedException snre )
>         {
>             System.out.println( "feature not supported: " +
> snre.getMessage() );
>             snre.printStackTrace();
>         }
>         catch ( Exception other )
>         {
>             other.printStackTrace();
>         }
>     }
> 
>     //~ Static variables
> -------------------------------------------------------
> 
>     private static final String VALIDATE_XML_FEATURE =
>         "http://xml.org/sax/features/validation";
>     private static final String WARN_ON_UNDECLARED_ELEMENT =
> 
> "http://apache.org/xml/features/validation/warn-on-undeclared-elemdef";
>     private static final String WARN_ON_DUPICATE_ENTITY =
>         "http://apache.org/xml/features/warn-on-duplicate-entitydef";
> }
> 
> When I run the code, however, I get this error:
> 
> C:\Documents and Settings\mhannaford\Desktop\test>java -classpath .
> TestSAXParser
> feature not supported: Feature
> 'http://apache.org/xml/features/validation/warn-on-undeclared-elemdef'
> is not recognized.
> org.xml.sax.SAXNotRecognizedException: Feature
> 'http://apache.org/xml/features/validation/warn-on-undeclared-elemdef'
> is not recognized.
>         at
> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.setFeature(
> Unknown Source)
>         at
> com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.setFeatures(Unknow
> n Source)
>         at
> com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.init(Unknown
> Source)
>         at
> com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.<init>(Unknown
> Source)
>         at
> com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl.newSAXParse
> rImpl(Unknown Source)
>         at
> com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl.setFeature(
> Unknown Source)
>         at TestSAXParser.main(TestSAXParser.java:22)
> 
> Is there something obvious I am doing wrong, or is the feature not
> enabled in this version of Xerces?
> 
> Thanks for your help.
> 
> --
> Michael Hannaford
> State of California
> Child Support Enforcement project
> 916-290-8993
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org
> 


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