Hi, I'm trying to write a schema using the 1.1 schema language and I need to be able to set the targetNamespace attribute on some of the elements. When I try and create a Validator to validate XML against the schema however, I get an instance of XMLSchema11Factory but when I pass the XSD file to the factory's newSchema() method I always get the following exception:
s4s-att-not-allowed: Attribute 'targetNamespace" cannot appear in element 'element'. I've trimmed the XSD down to a minimal test case that reproduces the problem: <?xml version="1.0" encoding="UTF-8"?> <xs:schema targetNamespace="http://www.foo.com" xmlns="http://www.foo.com" xmlns:other="http://www.bar.com" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element targetNamespace="http://www.bar.com"> <xs:simpleType name="ans"> <xs:restriction base="xs:string"/> </xs:simpleType> </xs:element> </xs:schema> And here is the code I'm using to try and create the validator System.setProperty("javax.xml.validation.SchemaFactory:http://www.w3.org/XML/XMLSchema/v1.1", "org.apache.xerces.jaxp.validation.XMLSchema11Factory"); SchemaFactory factory = SchemaFactory.newInstance("http://www.w3.org/XML/XMLSchema/v1.1"); Schema schema = factory.newSchema(new StreamSource(ClassLoader.getSystemResourceAsStream("test.xsd"))); xmlValidator = schema.newValidator(); Does anyone have any idea why this isn't working? Kind regards, Julian --------------------------------------------------------------------- To unsubscribe, e-mail: j-users-unsubscr...@xerces.apache.org For additional commands, e-mail: j-users-h...@xerces.apache.org