[thelist] XSLT XML output to XML

David Johansson thelist at dlade.net
Tue Apr 17 09:07:33 CDT 2007

Jon Molesa wrote:
> The match syntax isn't related to Regex?

Not really, no.

Just for fun, let's go through the match XPath part by part:

match="gnc:transaction[.//slot:key[normalize-space(.) =

We start off by matching any gnc:transation elements and then test on 
them (the first set of []) for any descendant (.// takes any descendant 
from the current location, while // matches anything from the root node) 
slot:key element.

We then test on that slot:key (with the second []) to see if the text 
value of it matches 'gncInvoice'.

The function normalize-space() strips whitespace from the start and end 
(and reduces any multiple whitespaces inside the content to single ones) 
of whatever you pass into it, which in our case is the current node, 
".", meaning the slot:key element we're currently testing on.

I haven't done any XSLT/Xpath for over two years now, so thanks for 
bringing back the memories. =)


More information about the thelist mailing list