Module transform

This module provides a couple of simple utilities to deal with the validation and application of XSL models. When a XSL model is validated, the referenced XML data is validated via its associated XSD schema. The predicates schema_new/1 and schema_digest/2 allow creating an XSD schema. An XML model is validated by the predicate data_check/3.

Example:
?- open('hello_buggy.xsl', read, S), elem_new(D),
node_load(D, S, [root(text)]), close(S), assertz(my_data(D)).
?- my_data(D), sheet_check(D,[]).
Error: Undeclared XPath variable.

The XSL model loads referenced data or schema via reflection. The result should be an in-stance that implements the Java interface InterfacePath. We currently use the standard Java class loader to create the instance. Using the class loader from the Prolog knowledge base is planned for future releases of this module.

Example:
?- ?- open('hello_english.xsl', read, S), elem_new(D),
node_load(D, S, [root(text)]), close(S), assertz(my_data(D)).
?- my_data(D), current_output(S),
sheet_transform(D, S, '', [variable(name,'John')]).
Welcome John!

XSL model select data fragments by XPath expressions. These expressions are parsed on the fly. During validation they advanced the current schema, whereas during application they advanced the current data. XSL models can be validated by the predicate sheet_check/2 and applied by the predicate sheet_transform/4.

The following transform predicates are provided:

schema_new(S):
The predicate succeeds in S with a new XSD schema.
schema_digest(S, D):
The predicate succeeds in digesting the DOM element D into the XSD schema S.
data_check(D, S, O):
The predicate succeeds in checking the DOM node D versus the XSD schema S with the DOM options O.
sheet_transform(T, S, C, O):
The predicate succeeds in transforming the DOM node T into the stream S with comment C and the XSL options O. The following XSL options are recognized:

root(M): M is the root mask.
type(E,T): T is the complex type for the element E.
variable(N,V): V is the value of the variable N.

The root mask can take the values list and text. The default value is text. The complex type can take the values empty and any. The variable values can be atoms and integers.
sheet_check(T, O):
The predicate succeeds in checking the DOM node T with the XSL options O.

Kommentare