-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document SAX usage #263
Comments
I am also interested in this issue. My approach is basically the same as in your code. I have found that reader.setProperty("http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation",
schemaFilename); When I add this line the error message that I get after the parse has begun is:
If I comment out the line reader.setFeature("http://apache.org/xml/features/validation/schema", true); then the error becomes
My guess is that the Here is a more complete example: System.setProperty(SchemaFactory.class.getName() + ":" + XMLConstants.RELAXNG_NS_URI, "com.thaiopensource.relaxng.jaxp.XMLSyntaxSchemaFactory");
SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.RELAXNG_NS_URI);
Schema schema = sf.newSchema(scf);
SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setSchema(schema);
try {
SAXParser parser = factory.newSAXParser ();
System.err.println("parser schema="+parser.getSchema());
XMLReader reader = parser.getXMLReader ();
reader.setFeature("http://xml.org/sax/features/validation", true);
reader.setFeature("http://apache.org/xml/features/validation/schema", true);
reader.setProperty("http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation",
schemaFilename);
reader.setFeature("http://apache.org/xml/features/xinclude", true);
reader.setFeature("http://xml.org/sax/features/namespaces", true);
reader.setFeature("http://apache.org/xml/features/xinclude/fixup-base-uris", false);
reader.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
reader.setErrorHandler (this);
reader.setContentHandler (this);
reader.setEntityResolver (this);
reader.parse (new InputSource(input)); As a workaround I am using trang to convert rng to xsd, and then validation with the built in XML Schema validator works just fine. I would be nice to only work with RelaxNG, and not have to convert to xsd, but it's not a show stopper. |
May I suggest to include in the README (or elsewhere) an example use for using Jing through the standard SAX API? (Issue #21 provides some partial example, but unfortunately the link provided there is dead.)
Here is an attempt of mine, so far unsuccessful.
Then test as follows. Using docbook howto.xml and docbook.rng.
The above test yields:
But that file does validate against that schema when not going through SAX (using
com.thaiopensource.validate.Schema schema = new AutoSchemaReader().createSchema(relaxSchema, countingErrorProperties); Validator validator = schema.createValidator(countingErrorProperties); contentHandler = validator.getContentHandler(); xmlReader = ResolverFactory.createResolver(PropertyMap.EMPTY).createXMLReader();
and so on…)Could you perhaps indicate what the recommended usage is for using Jing through the SAX interface?
Thank you for this useful library.
The text was updated successfully, but these errors were encountered: