| 1 |
package com.thaiopensource.validate.rng; |
| 2 |
|
| 3 |
import com.thaiopensource.relaxng.parse.sax.SAXParseReceiver; |
| 4 |
import com.thaiopensource.resolver.xml.sax.SAXResolver; |
| 5 |
import com.thaiopensource.util.PropertyMap; |
| 6 |
import com.thaiopensource.validate.Option; |
| 7 |
import com.thaiopensource.validate.ResolverFactory; |
| 8 |
import com.thaiopensource.validate.ValidateProperty; |
| 9 |
import com.thaiopensource.validate.auto.SchemaReceiver; |
| 10 |
import com.thaiopensource.validate.auto.SchemaReceiverFactory; |
| 11 |
import com.thaiopensource.validate.prop.rng.RngProperty; |
| 12 |
import com.thaiopensource.validate.rng.impl.SchemaReceiverImpl; |
| 13 |
import com.thaiopensource.xml.util.WellKnownNamespaces; |
| 14 |
import org.xml.sax.ErrorHandler; |
| 15 |
|
| 16 |
public class SAXSchemaReceiverFactory implements SchemaReceiverFactory { |
| 17 |
public SchemaReceiver createSchemaReceiver(String namespaceUri, |
| 18 |
PropertyMap properties) { |
| 19 |
// XXX allow namespaces with incorrect version |
| 20 |
if (!WellKnownNamespaces.RELAX_NG.equals(namespaceUri)) |
| 21 |
return null; |
| 22 |
SAXResolver resolver = ResolverFactory.createResolver(properties); |
| 23 |
ErrorHandler eh = properties.get(ValidateProperty.ERROR_HANDLER); |
| 24 |
return new SchemaReceiverImpl(new SAXParseReceiver(resolver, eh), properties); |
| 25 |
} |
| 26 |
|
| 27 |
public Option getOption(String uri) { |
| 28 |
return RngProperty.getOption(uri); |
| 29 |
} |
| 30 |
} |