[Haskell-cafe] Haskell XSLT interpreter?

Colin Paul Adams colin at colina.demon.co.uk
Sun Feb 12 09:20:36 EST 2006

>>>>> "Neil" == Neil Mitchell <ndmitchell at gmail.com> writes:

    >> In what way is the document() function not pure?
    Neil> See [http://www.w3schools.com/xsl/func_document.asp]. In
    Neil> particular their example:

    Neil> <xsl:value-of
    Neil> select="document('celsius.xml')/celsius/result[@value=$value]"/>

    Neil> i.e. this function needs to load the file celsius.xml.

No - it needs to retrieve the resource named by the relative URI
If the base URI for the xsl:value-of element is a file URI, then this
will indeed be a file. But that does not NECESSARILY imply any I/O.

    >> That is, the static context is defined to include a mapping
    >> from URIs to document nodes, and document() returns those
    >> document nodes that it's argument nodes map to.

    Neil> I think I understand what you are saying, but might have
    Neil> missed slightly. While you can consider it as a mapping from
    Neil> URI to document node, there are an infinite number of URI's,
    Neil> and therefore an infinite amount of context. A more
    Neil> practical implementation would be to retrieve the document
    Neil> nodes as they are requested, and then cache them - but this
    Neil> means having IO to do the initial retrieve.

It does, in practise - but this might not be done as part of the
tranformation - it might be done as part of the preparation.

Likewise, in theory, parsing the initial XML document, and serialising
the result, are not necessarily done by the XSLT processor.
XSLT is defined as a transformation from an initial instance of the
XPath data model (i.e. a tree of nodes in memory) to a new instance of
the XPath data model.

In practise, an XSLT processor will usually parse an XML file and
serialise the result to a file (or network socket), but this is
tectonically not part of the transformation.
Colin Adams
Preston Lancashire

More information about the Haskell-Cafe mailing list