xsl-list
[Top] [All Lists]

RE: [xsl] XQuery Updates in XSLT

2008-10-30 08:21:59
No, not at all. XQuery Update is 100% functional in the 
strict computer science sense of the work. It returns two 
types of values, an XDM and a list of updates that need to be 
applied (called a pending update list, PUL). All actual 
updates happen after the finish of the query, meaning that 
the query still behaves functionally.

A problem with that definition is that the things in the Pending Update List
are not values that can be manipulated by functions within the language;
indeed, an updating operation is not a function, because it cannot be
composed with other functions, because the results are not accessible until
the end. I think that function composition is an essential ingredient of a
functional language.

If you confine yourself to the copy-modify expression (called a "transform"
expression for historic reasons), which creates a copy and then returns the
result of updating the copy, then you do have something which is
functionally well-behaved, and which indeed allows certain kinds of changes
to a document to be expressed using syntax which is fairly succinct and
intuitive. 

(I don't accept Dimitre's criticisms about the complexity of the
specification; specifying the exact behaviour of "rename a as b" in terms of
the namespaces that are present in the result document is always going to
involve a horrendous amount of specification text to cover all corner cases,
but most users will never need to care.)

As for allowing updates in saxon:query(), I may well do so, with the
semantics of the "copy-modify" expression - you get back a modified copy of
the original, with the original unchanged. That seems cleanly functional to
me. Anything else (in-situ modification) would break the XSLT execution
model entirely. 

Michael Kay
http://www.saxonica.com/


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--