Schematronpublic class Schematron extends Object This class implements the final transformation in the multi-step
Schematron validation process. It is assumed that the user knows
something about Schematron.
Schematron instances are not thread-safe. Each instance can only be
used in a single thread, but each instance can be used multiple
times in sequence.
We use the default Transformer, as per the
javax.xml.transform.TransformFactory class. It is important that
the transformer be compatable with the stylesheet being used, but
apart from that this class has no constraints on these objects. It
simply provides a convenient wrapper for obtaining a validator. |
Fields Summary |
---|
private Transformer | transformer |
Constructors Summary |
---|
Schematron(String schemaName)Construct an instance which will use the given resource name
to find the schema to be used for subsequent analyses. The
schemaName is looked up as a resource on the classpath using
{@link Class.getResourceAsStream(schemaName)}.
transformer = getTransformer(schemaName);
|
Methods Summary |
---|
void | analyze(javax.xml.transform.Source src, javax.xml.transform.Result result)Analyse the given source onto the given result, using the
given schematron stylesheet, using XSLT transformations.
transformer.transform(src, result);
| private javax.xml.transform.Transformer | getTransformer(java.lang.String schema)
final InputStream is = this.getClass().getResourceAsStream(schema);
if (null == is){
throw new TransformerConfigurationException("Couldn't construct a transformer to perform validation because I couldn't find the resource named \""+schema+"\" from "+this.getClass().getName());
}
final TransformerFactory f = TransformerFactory.newInstance();
final Transformer t = f.newTransformer(new StreamSource(is));
return t;
|
|