Skip to content

LandrixXml 0.5.0

Latest

Choose a tag to compare

@landrix landrix released this 17 Nov 12:54
· 2 commits to main since this release

An XSLT 2.0 processor (LandrixXmlXslt, optional) that runs the KoSIT
report stylesheets and the XRechnung visualization with the output
Saxon HE writes, byte for byte; XPath 1.0 compatibility mode, SVRL into
an open writer with the message text as the rule file has it, and a
stack budget for deep recursion. The documented API only gains
additions.

Added

  • XSLT (LandrixXmlXslt, optional): a subset of XSLT 2.0 run as Saxon
    HE runs it, with TLandrixXmlXsltStylesheet (compiled once,
    immutable), TLandrixXmlXsltTransformer (parameters as strings, trees
    or XPath values, initial mode and template, output properties,
    messages), TLandrixXmlXsltResolver (imports and documents from files
    or a catalog, no network) and ELandrixXmlXsltError (an
    ELandrixXmlXPathError with the W3C code, the module and the line).
    See the README for the supported instructions; the KoSIT report
    stylesheet and the XRechnung visualization (XR XML and HTML) give the
    output Saxon gives, byte for byte.
    TLandrixXmlErrorCode gains xecXslt.
  • XSLT: system-property(), function-available() and
    element-available(); a name given with a prefix is resolved with the
    namespaces of the calling expression.
  • XSLT: output in US-ASCII and ISO-8859-1. A character the encoding does
    not have is a hexadecimal character reference in text and attribute
    values and SERE0008 elsewhere (comments, names, method text), as in
    Saxon.
  • XSLT: xsl:strip-space and xsl:preserve-space.
  • XSLT: use-when and xsl:use-when (conditional inclusion).
  • XSLT: xsl:sort (in xsl:for-each, xsl:apply-templates and
    xsl:for-each-group), xsl:perform-sort, xsl:analyze-string and
    regex-group().
  • XSLT: xsl:next-match and xsl:apply-imports (with xsl:with-param).
  • XSLT: xsl:attribute-set and use-attribute-sets (on literal result
    elements, xsl:element and xsl:copy).
  • XSLT: xsl:character-map and use-character-maps (on xsl:output
    and xsl:result-document), applied by the xml, html, xhtml and text
    output methods as in Saxon.
  • XSLT: xsl:namespace. An excluded namespace that a literal result
    element or its attribute uses is no longer a namespace node of its own:
    the namespace fixup declares it, as in Saxon. The fixup keeps an
    attribute's own prefix where nothing on the element binds it otherwise
    and names new prefixes as Saxon does. exclude-result-prefixes now
    excludes the namespace URIs bound where it is, not every later binding
    of the same prefix.
  • XSLT: xsl:namespace-alias (literal result elements, their attributes
    and namespace nodes; an aliased or alias result namespace is copied
    even when excluded).
  • XSLT: simplified stylesheets (a literal result element with
    xsl:version as a stylesheet module).
  • XSLT: xpath-default-namespace and xsl:xpath-default-namespace.
  • XSLT: xml:base in a stylesheet: the static base URI of the
    instructions below it (static-base-uri(), resolve-uri(), doc(),
    document(), unparsed-text()), the href of xsl:include and
    xsl:import, and the base URI of the temporary trees an instruction
    makes and of nodes made or copied at the top of a sequence, as Saxon
    gives them.
  • XSLT: xsl:key with a sequence constructor instead of use, and key
    names with a prefix (key() resolves it with the namespaces of the
    calling expression).
  • XSLT: English words and ordinals as Saxon HE writes them, in
    xsl:number (format="w", "W", "Ww", ordinal) and in the
    pictures of format-date() and its relatives ([Dwo], [D1o], also
    letters [Da]). xsl:number accepts lang (an invalid language code
    is XTDE0030; the numbers stay English, as in Saxon HE) and
    letter-value. A year cut to a maximum width is its last digits as a
    number, as in Saxon ([Y1,*-3] of 2013 is 13, no longer 013).
  • XSLT: [xsl:]expand-text (XSLT 3.0 text value templates, as Saxon
    also runs them in a stylesheet with version="2.0"): text in a sequence
    constructor and in xsl:text with expressions in braces ({{ and }}
    for braces, empty braces for the empty sequence); XTSE0350,
    XTSE0370 and XTSE0020 as for attribute value templates.
  • XSLT: copy-namespaces="no" on xsl:copy and xsl:copy-of: a copy
    has the namespaces its names need; below the top of a deep copy an
    element has those and the ones of the place the copy goes to, as
    Saxon writes them (also xmlns="" or a declaration repeated).
    true/1/false/0 are accepted as in Saxon; another value is
    XTSE0020.
  • XSLT: the output property byte-order-mark for every output method:
    as in Saxon the byte order mark is written for UTF-8 only (none for
    US-ASCII or ISO-8859-1); TransformToUtf8 and SerializeToUtf8 begin
    with it when the encoding asked for is UTF-8.
  • XSLT: disable-output-escaping on xsl:text and xsl:value-of, as
    in Saxon: text written to the final result tree (also by
    xsl:result-document) is serialized without escaping; the character
    map, normalization and character references for characters the
    encoding lacks still apply, and a CDATA section ends before it. A text
    node a function or a template with as returns stays raw when it is
    added to the result (not when it is copied with xsl:copy-of). It is
    ignored in temporary trees, attributes and comments, and when the
    result is returned as a tree; where Saxon keeps it in a node built in
    a sequence or in a temporary tree it is xecUnsupported at run time.
    Besides yes and no, true, 1, false and 0 are accepted as in
    Saxon; another value is XTSE0020.
  • XSLT: a collation URI that is not known as a collation is the error
    of the specification: XTDE1035 (xsl:sort), XTDE1110
    (xsl:for-each-group; FOCH0002 for a computed one, as in Saxon),
    XTSE1210 (xsl:key), XTSE0125 (default-collation without a known
    collation). default-collation takes the first known collation of its
    list, and the collation of xsl:for-each-group may be an attribute
    value template. UCA, Saxon and html-ascii-case-insensitive
    collations remain unsupported.
  • XSLT: the output property normalization-form (NFC, NFD, NFKC, NFKD,
    none) for every output method: text, attribute values and CDATA
    sections are normalized, names and comments are not; as in Saxon the
    character map comes first and its strings are not normalized. Another
    value (also fully-normalized) is SESU0011 when the result is
    serialized.
  • XSLT: forwards compatible processing for a version above 3.0, as in
    Saxon: unknown declarations are ignored with their content, an unknown
    instruction runs its xsl:fallback (XTSE0010 without one), unknown
    attributes of XSLT elements are ignored. A version that is no decimal
    is XTSE0110 (one below 2.0: backwards compatible processing, below).
  • XSLT: extension-element-prefixes (also on xsl:template and other
    XSLT elements, and as xsl:extension-element-prefixes on literal
    result elements). No extension instruction is known: an element in an
    extension namespace runs its xsl:fallback children, or raises
    XTDE1450 when it is evaluated without one; the extension namespaces
    are not copied to literal result elements. As in Saxon, #default
    means no namespace.
  • XSLT: doctype-system and doctype-public (xml and xhtml: with a
    system identifier; html: either, the name html), written as Saxon
    writes them before the first element; with doctype-system or
    standalone a second element or text at the top is SEPM0004; a
    public identifier with a character other than the XML PubidChar (or a
    tab), or a system identifier with both quote characters, is
    XTSE0020.
  • XSLT: cdata-section-elements on xsl:output (the union of every
    definition) and xsl:result-document (added to the format's), for the
    xml and xhtml methods. The text of those elements is written in CDATA
    sections as Saxon writes them: ]]> split, a character the encoding
    does not have as a character reference between sections, no character
    map. The output property holds the Clark names.
  • XSLT: document() with a second argument (the base URI of that node for
    every relative URI; XPTY0004 for no single node, XTDE1162 without a
    base URI).
  • XPath: TLandrixXmlXPathStaticContext.DefaultElementNamespace (the
    default element/type namespace, '' unless set), also readable on the
    compiled expression.
  • XSLT: the output method xhtml, as Saxon writes it (also the default
    method for an html root element in the XHTML namespace).
  • XSLT: tunnel parameters (tunnel="yes" on xsl:with-param and
    template parameters). An initial template with a required parameter is
    XTDE0060, as in XSLT 2.0.
  • XSLT: xsl:result-document and named xsl:output definitions.
    Secondary results are collected by the transformer
    (ResultDocumentCount, ResultDocuments, FindResultDocument,
    TLandrixXmlXsltResultDocument), href resolves against the new
    BaseOutputUri; nothing is written to disk.
  • tools/run-xslt-tests.py runs the XSLT 1.0 and 2.0 cases of the W3C
    XSLT test suite against a baseline (tests/data/xslt-baseline.txt).
  • XPath: the string concatenation operator || (XPath 3.0) in the
    xppSaxon profile, as Saxon accepts it in stylesheets that declare
    XSLT 2.0; a || b || c is concat(a, b, c). The xppXPath20 profile
    rejects it with XPST0003.
  • XPath: XPath 1.0 compatibility mode
    (TLandrixXmlXPathStaticContext.XPath10Compatible, default False,
    kept by each expression): function arguments take the first item and
    are converted with fn:string or fn:number, arithmetic works on the
    first items as xs:double (NaN for an empty operand), and general
    comparisons follow XPath 1.0, all as in Saxon. Arguments of user
    functions follow the caller's mode.
  • XSLT: backwards compatible processing. A stylesheet or element with a
    version below 2.0 (an XSLT 1.0 stylesheet) is no longer rejected: its
    expressions run in XPath 1.0 compatibility mode, xsl:value-of,
    attribute value templates, xsl:number and sort keys take the first
    item, key() compares strings, an undeclared parameter is ignored and
    function arguments are converted as in XPath 1.0, as Saxon does.
    system-property('xsl:supports-backwards-compatibility') is yes.
  • tools/xslt-crosscheck.py --config bis|zugferd|all also checks the
    report stylesheets of the Peppol BIS and ZUGFeRD configurations of the
    KoSIT validator (each with its own default-report.xsl), and every
    configuration with a schema error, a document that is not well-formed
    and one no scenario matches.
  • Schematron: SaveSvrlToWriter writes the SVRL element into an open
    writer (SaveSvrlToStream calls it, its output is unchanged);
    RawMessage on the results is the message with the white space of the
    rule file, and SvrlPreserveWhitespace writes it into svrl:text as
    SchXslt and the KoSIT validator do.
  • XPath and XSLT: MaxStackBytes on TLandrixXmlXPathEvaluator and
    TLandrixXmlXsltTransformer, a budget for the stack nested user
    functions and templates may use; beyond it the run stops with
    FOER0000 (xecLimit) instead of overflowing the stack. The default,
    LandrixXmlDefaultMaxStackBytes, is 3/4 of the program's stack size on
    Windows and 0 (no budget) elsewhere.

Changed

  • Schematron: text in an assert or report that is only white space
    (between two sch:value-of, for example) is left out by the compiler
    and tools/sch-compile.py, as the XSLT processor strips it from the
    stylesheet SchXslt generates.
  • XPath: a call of a user function no longer goes through the frame of
    the built-in functions; a level of the stylesheet recursion of the W3C
    case function-0701 takes 2.4 KB of stack instead of 8.4 KB with Delphi
    Win64, where it overflowed the 1 MB stack.
  • XSLT: the XML output writes U+007F to U+009F and U+2028 as character
    references, as Saxon does.
  • XSLT: an XPath comment inside the braces of an attribute value
    template may contain braces.
  • XSLT: white space in the stylesheet is stripped after comments and
    processing instructions are removed (text around a comment is one text
    node), and white space before xsl:param and xsl:sort is stripped
    even under xml:space="preserve".
  • XPath: distinct-values() finds repeated strings through a hash table:
    120,000 values with 60,000 distinct strings took more than ten
    minutes, now about two seconds.

Fixed

  • XSLT: exclude-result-prefixes on XSLT elements other than
    xsl:stylesheet (for example xsl:template) was ignored.