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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]