notify-dpml AT lists.ibiblio.org
Subject: DPML Notify
List archive
svn commit: r1318 - in development/main/metro/composition/test: . etc/test src/test/net/dpml/composition/util
- From: pneubauer AT netcompartner.com
- To: notify-dpml AT lists.ibiblio.org
- Subject: svn commit: r1318 - in development/main/metro/composition/test: . etc/test src/test/net/dpml/composition/util
- Date: Tue, 28 Dec 2004 22:43:08 +0100
Author: pneubauer
Date: Tue Dec 28 22:43:08 2004
New Revision: 1318
Removed:
development/main/metro/composition/test/ConfigurableB.xschema
Modified:
development/main/metro/composition/test/etc/test/ConfigurableB.xml
development/main/metro/composition/test/src/test/net/dpml/composition/util/SchemaValidationTestCase.java
Log:
Going for plain schema validation without JAXP, directly Xerces, now
Modified: development/main/metro/composition/test/etc/test/ConfigurableB.xml
==============================================================================
--- development/main/metro/composition/test/etc/test/ConfigurableB.xml
(original)
+++ development/main/metro/composition/test/etc/test/ConfigurableB.xml Tue
Dec 28 22:43:08 2004
@@ -1,5 +1,3 @@
-<?xml version="1.0"?>
-<!--A Sample Configuration snippet-->
<configuration attr1="foo">
<child1/>
</configuration>
Modified:
development/main/metro/composition/test/src/test/net/dpml/composition/util/SchemaValidationTestCase.java
==============================================================================
---
development/main/metro/composition/test/src/test/net/dpml/composition/util/SchemaValidationTestCase.java
(original)
+++
development/main/metro/composition/test/src/test/net/dpml/composition/util/SchemaValidationTestCase.java
Tue Dec 28 22:43:08 2004
@@ -6,9 +6,8 @@
import java.io.InputStream;
import java.util.Hashtable;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
+import org.apache.xerces.parsers.SAXParser;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.SAXNotRecognizedException;
@@ -54,6 +53,7 @@
public void error( SAXParseException e ) throws SAXException
{
m_errors.put("lastError", e);
+ e.printStackTrace();
}
/**
@@ -109,39 +109,36 @@
}
}
- public void _testParsingOfValidatingXMLNotOKWhenUsingStream() throws
Exception
+ public void testParsingOfValidatingXMLNotOKWhenUsingFiles() throws
Exception
{
- SAXParserFactory factory = SAXParserFactory.newInstance();
- factory.setValidating( true );
- factory.setNamespaceAware( true );
- SAXParser saxParser = factory.newSAXParser();
+ SAXParser saxParser = new SAXParser();
System.out.println("XML parser: " + saxParser);
- if (saxParser instanceof org.apache.xerces.jaxp.SAXParserImpl)
- {
- try
+ try
{
saxParser.setProperty( JAXP_SCHEMA_LANGUAGE,
W3C_XML_SCHEMA );
+ String schemaLocation = "ConfigurableB.xschema";
+
saxParser.setFeature("http://xml.org/sax/features/validation", true);
+
saxParser.setFeature("http://apache.org/xml/features/validation/schema",
+ true);
+
saxParser.setFeature("http://apache.org/xml/features/validation/schema-full-checking",true);
+ saxParser.setProperty(
+
"http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation",
+ schemaLocation);
}
catch ( SAXNotRecognizedException x )
{
- fail( "parser does not support JAXP1.2" );
+ fail( "could not set property " + x );
}
- }
- String basedir = System.getProperty( "project.dir" );
- //System.out.println( basedir );
- File xmlFile = new File( basedir, "SelfValidatingConfigurableB.xml"
);
TestHandler testHandler = new TestHandler();
- saxParser.parse( xmlFile, testHandler );
- assertEquals( 0, testHandler.getErrors().size() );
- InputStream is = new FileInputStream( xmlFile );
- saxParser.parse( new InputSource( is ), testHandler );
- assertEquals( 0, testHandler.getErrors().size() );
+ saxParser.setErrorHandler(testHandler);
+ saxParser.parse( "target/test/ConfigurableB.xml" );
+ assertEquals(0, testHandler.m_errors.size());
}
- public void testDummyAlwaysTrue()
+ public void _testDummyAlwaysTrue()
{
//System.out.println(System.getProperties());
assertTrue( true );
- svn commit: r1318 - in development/main/metro/composition/test: . etc/test src/test/net/dpml/composition/util, pneubauer, 12/28/2004
Archive powered by MHonArc 2.6.24.