Class Transform
java.lang.Object
org.libxmq.imp.xml.libxslt1.Transform
XSLT 1.0 transformations, a port of libxslt transform.c, variables.c, templates.c,
keys.c, functions.c, numbers.c and documents.c onto the dom and xpath of libxmq (the port
of src/main/c/parts/xml_libxslt1_transform.c). The stylesheet is compiled with
Xslt.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe output method html.static final intThe output method text.static final intThe output method xml of a result (the same numbers as libxslt xsltOutputType). -
Method Summary
Modifier and TypeMethodDescriptionstatic XmlDocumentapplyStylesheet(Stylesheet style, XmlDocument doc, String[] params, int[] output_type) Apply the stylesheet to the document (libxslt xsltApplyStylesheet, port of xsltApplyStylesheetInternal).static XmlDocumentcopyStylesheetDoc(Stylesheet style) A copy of the (compiled) stylesheet document, like the xmlCopyDoc loaders give for document('').static byte[]saveResultToString(XmlDocument result, Stylesheet style, int output_type) Serialize a result like libxslt xsltSaveResultToString: the output method, encoding, indentation, xml declaration and doctype of the stylesheet (xml_libxslt1_save_result_to_string).static voidFree a transformation (xml_libxslt1_transform_free): the result tree fragments and the documents loaded by document() are released.static TransformCtxtransformNew(Stylesheet style, XmlDocument source) A transformation context for the source document (not owned).
-
Field Details
-
OUTPUT_XML
public static final int OUTPUT_XMLThe output method xml of a result (the same numbers as libxslt xsltOutputType).- See Also:
-
OUTPUT_HTML
public static final int OUTPUT_HTMLThe output method html.- See Also:
-
OUTPUT_TEXT
public static final int OUTPUT_TEXTThe output method text.- See Also:
-
-
Method Details
-
copyStylesheetDoc
A copy of the (compiled) stylesheet document, like the xmlCopyDoc loaders give for document('').- Parameters:
style- The stylesheet.- Returns:
- The copy or null.
-
transformNew
A transformation context for the source document (not owned). Compile the patterns before creating it, like libxslt allocates their caches (xml_libxslt1_transform_new).- Parameters:
style- The stylesheet.source- The source document.- Returns:
- The transformation.
-
transformFree
Free a transformation (xml_libxslt1_transform_free): the result tree fragments and the documents loaded by document() are released.- Parameters:
t- The transformation.
-
saveResultToString
Serialize a result like libxslt xsltSaveResultToString: the output method, encoding, indentation, xml declaration and doctype of the stylesheet (xml_libxslt1_save_result_to_string).- Parameters:
result- The result document.style- The stylesheet.output_type- What applyStylesheet gave.- Returns:
- The bytes in the output encoding.
-
applyStylesheet
public static XmlDocument applyStylesheet(Stylesheet style, XmlDocument doc, String[] params, int[] output_type) Apply the stylesheet to the document (libxslt xsltApplyStylesheet, port of xsltApplyStylesheetInternal). The document is not owned but whitespace may be stripped from it (xsl:strip-space).- Parameters:
style- The stylesheet.doc- The source document.params- Name, value pairs (the values are xpath expressions) or null.output_type- If not null, output_type[0] gets OUTPUT_XML, OUTPUT_HTML or OUTPUT_TEXT.- Returns:
- The result, null after reporting errors.
-