| 1 |
package com.thaiopensource.relaxng.jaxp; |
| 2 |
|
| 3 |
import com.thaiopensource.relaxng.parse.Parseable; |
| 4 |
import com.thaiopensource.relaxng.parse.sax.SAXParseable; |
| 5 |
import com.thaiopensource.relaxng.pattern.Pattern; |
| 6 |
import com.thaiopensource.relaxng.pattern.NameClass; |
| 7 |
import com.thaiopensource.relaxng.pattern.CommentListImpl; |
| 8 |
import com.thaiopensource.relaxng.pattern.AnnotationsImpl; |
| 9 |
import com.thaiopensource.resolver.xml.sax.SAXResolver; |
| 10 |
import com.thaiopensource.validation.Constants; |
| 11 |
import com.thaiopensource.util.VoidValue; |
| 12 |
import org.xml.sax.ErrorHandler; |
| 13 |
import org.xml.sax.SAXException; |
| 14 |
import org.xml.sax.Locator; |
| 15 |
|
| 16 |
import javax.xml.transform.sax.SAXSource; |
| 17 |
|
| 18 |
/** |
| 19 |
* A SchemaFactory that supports RELAX NG with the original XML syntax. |
| 20 |
*/ |
| 21 |
public class XMLSyntaxSchemaFactory extends SchemaFactoryImpl { |
| 22 |
|
| 23 |
/** |
| 24 |
* The String that is used to identify the schema language, when the schema language is RELAX NG with the original |
| 25 |
* XML syntax. The String is the namespace URI for RELAX NG schemas. |
| 26 |
*/ |
| 27 |
static final public String SCHEMA_LANGUAGE = Constants.RELAXNG_XML_URI; |
| 28 |
|
| 29 |
protected Parseable<Pattern, NameClass, Locator, VoidValue, CommentListImpl, AnnotationsImpl> createParseable(SAXSource source, SAXResolver resolver, ErrorHandler eh) throws SAXException { |
| 30 |
if (source.getXMLReader() == null) |
| 31 |
source = new SAXSource(resolver.createXMLReader(), source.getInputSource()); |
| 32 |
return new SAXParseable<Pattern, NameClass, Locator, VoidValue, CommentListImpl, AnnotationsImpl>(source, resolver, eh); |
| 33 |
} |
| 34 |
|
| 35 |
public boolean isSchemaLanguageSupported(String schemaLanguage) { |
| 36 |
return schemaLanguage.equals(SCHEMA_LANGUAGE); |
| 37 |
} |
| 38 |
|
| 39 |
} |