[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: How to parse a fragment result tree in the context

Subject: Re: How to parse a fragment result tree in the context of inputtree
From: Mike Brown <mike@xxxxxxxx>
Date: Fri, 1 Jun 2001 10:16:02 -0600 (MDT)
fragment tree
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.