[Haskell-cafe] Haskell XSLT interpreter?

Lennart Augustsson lennart at augustsson.net
Sun Feb 12 15:30:17 EST 2006


Neil Mitchell wrote:
>> In what way is the document() function not pure?
> 
> See [http://www.w3schools.com/xsl/func_document.asp]. In particular
> their example:
> 
> <xsl:value-of select="document('celsius.xml')/celsius/result[@value=$value]"/>
> 
> i.e. this function needs to load the file celsius.xml. Note that
> instead of celsius.xml there could be an arbitrary complex expression
> here, that builds up a filename.
> 
> 
>> 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.
> 
> I think I understand what you are saying, but might have missed
> slightly. While you can consider it as a mapping from URI to document
> node, there are an infinite number of URI's, and therefore an infinite
> amount of context. A more practical implementation would be to
> retrieve the document nodes as they are requested, and then cache them
> - but this means having IO to do the initial retrieve.

A function you could have in Haskell that would make some of these
things pure is
	getFileReader :: IO (FilePath -> String)
which would return a (semantically pure) function that maps file
names to file contents.

	-- Lennart


More information about the Haskell-Cafe mailing list