xsl-list
[Top] [All Lists]

RE: design question on function namespaces

2005-05-03 05:58:03
I think based on this, I'm going to try where possible to have logic 
defined in functions, and in xpath (2.0) rather than pure XSLT.

One design question: Mike Kay in his book on XSLT 2.0 advocates 
function namespaces based on the namespace of the data they work on.


The thinking here is that it's often useful to create a library of reusable
functions that compute derived data from your source document: for example,
"does this chapter have any footnotes" or "how many columns are there in
this table" or "is this employee in the pension scheme" or "get all the
products that this customer has bought". You should think of these as
methods associated with the element in question (even though there's no
encapsulation or inheritance), and recognize the link between code and data
by matching up the namespace.

By contrast, I tend to give local functions that are unique to one
particular module a namespace that ties them to that module (again, there's
not really such a thing as a local/private function in XSLT, but you can use
namespaces to pretend).

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>
--~--