Hey Guys, Can you give me a hand. I'm getting a weird error that I cannot replicate with jaxp.SourceValidator so I know I must be doing something wrong, but I can't tell what.
My code looks like this: package com.rackspace.xerces; import javax.xml.validation.*; import javax.xml.transform.stream.*; public class Test { public static void main(String[] args) { if (args.length != 2) { System.err.println ("Usage: need XSD and instance doc"); return; } try { System.setProperty ("javax.xml.validation.SchemaFactory:http://www.w3.org/XML/XMLSchema/v1.1";, "org.apache.xerces.jaxp.validation.XMLSchema11Factory"); String xsd = args[0]; String instance = args[1]; SchemaFactory factory = SchemaFactory.newInstance("http://www.w3.org/XML/XMLSchema/v1.1";); factory.setFeature ("http://apache.org/xml/features/validation/cta-full-xpath-checking";, true); Schema s = factory.newSchema(new StreamSource(xsd)); s.newValidator().validate(new StreamSource(instance)); } catch (Exception e) { e.printStackTrace(); } } } You pass a schema in param 1 and an instance document in param 2, the code validates and returns errors. Here's the schema I'm using to test: <schema elementFormDefault="qualified" attributeFormDefault="unqualified" xmlns="http://www.w3.org/2001/XMLSchema"; xmlns:xsd="http://www.w3.org/2001/XMLSchema"; xmlns:tst="http://www.rackspace.com/xerces/test"; targetNamespace="http://www.rackspace.com/xerces/test";> <element name="e" type="tst:SampleElement"/> <element name="a" type="tst:SampleAttribute"/> <complexType name="SampleElement"> <sequence> <element name="even" type="tst:EvenInt100" minOccurs="0"/> </sequence> </complexType> <complexType name="SampleAttribute"> <attribute name="even" type="tst:EvenInt100" use="optional"/> </complexType> <!-- XSD 1.1 assert --> <simpleType name="EvenInt100"> <restriction base="xsd:integer"> <minInclusive value="0" /> <maxInclusive value="100" /> <assertion test="$value mod 2 = 0" /> </restriction> </simpleType> </schema> When I pass the following instance document, the assertion in EvenInt100 trips and things fail as expected: <a xmlns="http://www.rackspace.com/xerces/test"; even="23"/> When I pass *this* instance document however, I'd expect the same assertion to fail, but it doesn't. <e xmlns="http://www.rackspace.com/xerces/test";> <even>23</even> </e> The very weird bit is that jaxp.SourceValidator works correctly on the example, so i must be doing something wrong...but I can't tell what it is. Any ideas? BTW my code is on github here: https://github.com/RackerWilliams/xerces-tests/tree/master/schema_tests You should be able to do a mvn clean install Then java -jar target/xerces-test-1.0.0-SNAPSHOT-jar-with-dependencies.jar test.xsd test.xml to illustrate the issue. Thanks, -jOrGe W. --------------------------------------------------------------------- To unsubscribe, e-mail: j-users-unsubscr...@xerces.apache.org For additional commands, e-mail: j-users-h...@xerces.apache.org