| 1 |
package com.thaiopensource.relaxng.jaxp; |
| 2 |
|
| 3 |
import com.thaiopensource.relaxng.parse.Parseable; |
| 4 |
import com.thaiopensource.relaxng.parse.compact.CompactParseable; |
| 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.SAX; |
| 10 |
import com.thaiopensource.resolver.xml.sax.SAXResolver; |
| 11 |
import com.thaiopensource.validation.Constants; |
| 12 |
import com.thaiopensource.util.VoidValue; |
| 13 |
import org.xml.sax.ErrorHandler; |
| 14 |
import org.xml.sax.Locator; |
| 15 |
|
| 16 |
import javax.xml.transform.sax.SAXSource; |
| 17 |
|
| 18 |
/** |
| 19 |
* A SchemaFactory that supports RELAX NG Compact Syntax. |
| 20 |
*/ |
| 21 |
public class CompactSyntaxSchemaFactory extends SchemaFactoryImpl { |
| 22 |
/** |
| 23 |
* The String that is used to identify the schema language, when the schema language is RELAX NG Compact Syntax. |
| 24 |
* Usually XML schema languages use an XML syntax, and the schema language can be identified by the namespace URI, |
| 25 |
* but this is not the case with RELAX NG Compact Syntax. RELAX NG Compact syntax has a registered MIME type, |
| 26 |
* which is application/relax-ng-compact-syntax, so we use the URI corresponding to that. |
| 27 |
* @see javax.xml.validation.SchemaFactory#isSchemaLanguageSupported |
| 28 |
* @see javax.xml.validation.SchemaFactory#newInstance(String) |
| 29 |
*/ |
| 30 |
static final public String SCHEMA_LANGUAGE = Constants.RELAXNG_COMPACT_URI; |
| 31 |
|
| 32 |
public boolean isSchemaLanguageSupported(String schemaLanguage) { |
| 33 |
return schemaLanguage.equals(SCHEMA_LANGUAGE); |
| 34 |
} |
| 35 |
|
| 36 |
protected Parseable<Pattern, NameClass, Locator, VoidValue, CommentListImpl, AnnotationsImpl> createParseable(SAXSource source, SAXResolver saxResolver, ErrorHandler eh) { |
| 37 |
return new CompactParseable<Pattern, NameClass, Locator, VoidValue, CommentListImpl, AnnotationsImpl>(SAX.createInput(source.getInputSource()), saxResolver.getResolver(), eh); |
| 38 |
} |
| 39 |
} |