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

Re: Fwd: xsl:key() and $variables.

Subject: Re: Fwd: xsl:key() and $variables.
From: "M. David Peterson" <m.david@xxxxxxxxxx>
Date: Fri, 21 Jul 2006 22:40:16 -0600
variable xsl key external document
Hi Steve,

A lot of people, myself included, have limited time, and simply can not spend the time doing the research on your previous threads such that we can gain better context as to what you mean.

With this in mind, if you want to find a solution to your problem, please provide more detail. In this case, there is simply not enough information here to make sense of what you are attempting to do. For example,

How does the variable that contains Records/Record gain access to this data? Is it an external XML document accessed via the document function? At first site, it seems as if your suggesting that the variable contains this XML data embedded directly inside of the opening and closing tag. Is this the case? If yes, are you using an XSLT 1.0 or XSLT 2.0 processor?

This is an important point to consider, as you may very well be stuck at a point that you didn't even realize existed, dealing with Result Tree Fragments that limit the operations that can be performed, without first being converted to a node-set. Unfortunately, converting an RTF to a node-set requires an external function, as this is not something that was a part of the XSLT 1.0 spec.

Setting this aside, lets assume that the Records/Record data set is an external document accessed via the document function. We know that the second set of XML, blah.xml, is an external document accessed via the document function. Whats missing now is understanding where this XML data is now stored such that we can use this as a point of reference for comparing with the Records/Record data-set.

With this information, we can then gain a better understanding as to how to properly process each XML data-set, using the distinct values of one data-set to compare against the other, and filter the result set based on a filtered criteria.

If I were to make an educated guess, it seems in this case you are desirous to obtain from the Records/Record/activity data-set, those 'activity' elements in which contains a text node who's string value is equal to the string value of the text node contained between the opening and closing activity element of the second data-set in which contains an attribute who's name is 'neccesary' and whos value is equal to = 'yes'.

In other words, you want to create an index with the second data set of only those elements in which contain a necessary attribute = 'yes'.

[From your sample]
<activity neccesary="yes">Writing</activity>

would be the only element that matches this criteria, although in the actual data there are probably others as well.


With the above index, you now want to parse through the first data set, and locate elements that contain the same string value, in this case 'Writing', outputting the result of this processing.

Is this correct?

If yes, then lets make sure you are operating on data that is a proper node-set instead of a RTF first, and move forward into understanding how to use keys to properly group and filter your data.

Steve wrote:

---------- Forwarded message ----------
From: Steve <subsume@xxxxxxxxx>
Date: Jul 20, 2006 3:41 PM
Subject: xsl:key() and $variables.
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx

I have a variable containing

   ......etc  (yes, I know they're not closed.)

and some xml (document('../blah.xml') containing...

   <activity neccesary="no">Baseball</
   <activity neccesary="no">Shopping</
   <activity neccesary="yes">Writing</


How do I  <xsl:apply-templates select="$variable/Records/Record[1]" />
only those records which are neccesary="yes"  ?

I swear one of these posts I'll have xsl:key figured out.


-- /M:D

M. David Peterson
http://mdavid.name | http://www.oreillynet.com/pub/au/2354 <http://www.oreillynet.com/pub/au/2354>

Current Thread


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.
First Name
Last Name
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.