[xsl] Re: Namespaces, params and Xalan

Subject: [xsl] Re: Namespaces, params and Xalan
From: Fraser Crichton <fraser.crichton@xxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 28 Sep 2004 11:22:16 +1200
Hi, Michael,

Many thanks for your feedback it was invaluable. I have a couple of questions

First, what is this?:
node()[(../. = /) and not(self::cmn:Comments)]
../. means the same as .., so you are trying to match any node whose parent
has a string-value that is the same as the string-value of the root node.
Getting the string-value of the root node is a pretty expensive operation,
it involves scanning the whole document. I suspect you are trying to match
the element whose parent is the root node, in which case you can write
match="/*".

I'd always thought "/*" was the same as "//node()" but I think what your are suggesting is that "/*" returns only those nodes immediately under the root and as a flat list and not everything in the document as flat list?


And the not(self::xxx) part is much better handled by defining a
second template rule with higher priority that has match="cmn:Comments".

So does that mean "priority" is less expensive than filters?


Secondly, in the JAXP code you are frequently using Windows filenames in
places where URIs are expected. Xalan may let you get away with this (I
don't know) but Saxon certainly won't.

Ah, that would explain that then.


Thirdly, this expression: [name()=name(current())] is pretty fragile in an
environment with so many namespaces, because you are comparing prefixes, not
URIs. Test whether the namespace-uri and local-name are both equal.

Presumably you are suggesting local-name() rather than name() in case the prefixes get confused for some reason?


Fourthly, you don't need xalan-nodeset(). The input is already a node-set,
you don't need to convert it.

Oops, that's a bit of a school boy error. Sorry, think it was 'cause I was originally working on the file with the param as a hardcoded string.



Finally, for debugging try simply doing <xsl:copy-of> on the supplied parameter in your match="/" template. Displaying the result of your complex path expression simply proves that your path expression is wrong.

I shall.

Thanks again, I really appreciate you taking the time to go through this - I know it must have been painful.

Fraser

--
Fraser Crichton
Web Developer
SolNet Solutions Limited
L12, SolNet House, 70 The Terrace
PO Box 397, Wellington, Aotearoa / New Zealand
www.solnetsolutions.co.nz <http://www.solnetsolutions.co.nz>
DDI: 04-462-5078
Mob: 027-278-3392
Fax: 04-462-5011
email: fraser.crichton@xxxxxxxxxxxxxxxxxxxxx <mailto:fraser.crichton@xxxxxxxxxxxxxxxxxxxxx>


Attention:
This email may contain information intended for the sole use of
the original recipient. Please respect this when sharing or
disclosing this email's contents with any third party. If you
believe you have received this email in error, please delete it
and notify the sender or postmaster@xxxxxxxxxxxxxxxxxxxxx as
soon as possible. The content of this email does not necessarily
reflect the views of SolNet Solutions Ltd.

Current Thread