Class Transform

java.lang.Object
org.libxmq.imp.xml.libxslt1.Transform

public final class Transform extends Object
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 Details

    • OUTPUT_XML

      public static final int OUTPUT_XML
      The output method xml of a result (the same numbers as libxslt xsltOutputType).
      See Also:
    • OUTPUT_HTML

      public static final int OUTPUT_HTML
      The output method html.
      See Also:
    • OUTPUT_TEXT

      public static final int OUTPUT_TEXT
      The output method text.
      See Also:
  • Method Details

    • copyStylesheetDoc

      public static XmlDocument copyStylesheetDoc(Stylesheet style)
      A copy of the (compiled) stylesheet document, like the xmlCopyDoc loaders give for document('').
      Parameters:
      style - The stylesheet.
      Returns:
      The copy or null.
    • transformNew

      public static TransformCtx transformNew(Stylesheet style, XmlDocument source)
      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

      public static void transformFree(TransformCtx t)
      Free a transformation (xml_libxslt1_transform_free): the result tree fragments and the documents loaded by document() are released.
      Parameters:
      t - The transformation.
    • saveResultToString

      public 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).
      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.