Subject: Re: [xsl] How to parse a fragment result tree in the context of input tree From: Mike Brown <mike@xxxxxxxx> Date: Fri, 1 Jun 2001 10:16:02 -0600 (MDT) |
Janning Vygen wrote: > the key problem is, that i can apply stylesheet to a fragment tree which is > created in a template, but this fragment tree doesnt know where it belongs in > the source tree. > > the second template generates a authorlist but can not include the proper > class. How can you apply templates to a result tree fragment and still have > access to the whole document?? The nodes in the fragment you created are not in the source tree. They are copies of what was in the source tree. In order to find the corresponding nodes in the real source tree, you need to do some comparisons. I don't know what your XML looks like, but the answer is something like this: (make this a top-level variable): <xsl:variable name="authors" select="/book/chapter/docinfo/authors/author"/> (then, in your template): <xsl:value-of select="$authors[. = current()]/ancestor::chapter/@id"/> Note that if you have multiple 'author' elements with the same string-value, the select will identify multiple 'id' attributes, and the value-of will only take the first of these, every time. Instead of applying templates to a result tree fragment that contains nodes copied from the source tree, you may want to see if your problem can be handled by only processing nodes in the source tree. This way, you won't have to try to go back and find the original nodes; you'll have them already. - Mike _____________________________________________________________________________ mike j. brown, software engineer at | xml/xslt: http://skew.org/xml/ webb.net in denver, colorado, USA | personal: http://hyperreal.org/~mike/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] outputting escaped charac, Mike Brown | Thread | [xsl] Inserting Elements with XSL, Joerg Pietschmann |
Re: [xsl] Book on XSP ?, Michael Beddow | Date | Re: [xsl] outputting escaped charac, Mike Brown |
Month |