[thelist] XSLT XML output to XML

Jon Molesa rjmolesa at consoltec.net
Tue Apr 17 09:50:06 CDT 2007

* David Johansson <thelist at dlade.net> wrote:

> match="gnc:transaction[.//slot:key[normalize-space(.) =
> 'gncInvoice']]"
What I don't exactly get is: do namespaces become part of the path?  I
can see it in gnc:transaction and slot:key, but does XPath require them
to transverse the tree?  Or is this one of the generally preferred way
to do things since it's more explicit?  IOW, would the above work
without the ns?

> 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.
Neat!  Not obvious syntax though.

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

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

Figured the normalize-space() as well, but it is a rather odd function
name.  At least when compared to programming languages.

So most of the syntax is about climbing the tree and not about matching
text?  The gncInvoice test is the only place we're "looking" at text.
Hmmm...  I'll need to think this over.  Is it fair to say then that most
of an XML file(not always true) is going to be structure, and small
amounts of content?  The "text" is both structure and content.  WOW!  I
know, you all are chuckling now.  It's ok.  I would too.

EVOLT is a great community and the people here are swell.  Another
Evolter was following this thread and sent me a private message offering
her assistance anytime I needed some advice on XSLT.  So thanks to the
both of you and I'm sure I'll seek your expertise again in the future.
Next time though I hope to have a better understanding.  Thanks again,
and I'm glad you had fun as well.

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

My pleasure.  :)

Jon Molesa

More information about the thelist mailing list