Re: How to parse a fragment result tree in the context
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
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format