|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Dynamic Tables
Jeff,
JP may have another word of explanation but I can throw some stuff in. Two things that you may already know, but we have to be clear on to avoid misconceiving the problem: * equality testing rules for node-sets -- in the XSLT spec at w3.org/TR/xpath -- two node-sets test as equal if either node set contains any node with the same (string) value as any node in the other node set. So ". = ../listing" tests true if the context node of the expression has the same value as any node in the set "../listing". * "../listing" is short for "parent::node()/child::listing". If the context node is a listing element, this will always test as true, since the context node itself is among the listing children of its parent. (Also defined in the XPath Rec.) If you want to test whether a node has the same value as any of its siblings (not the same as the children of its parent, which category of course includes itself), you can test ". = (preceding-sibling::* | following-sibling::*)" (or perhaps (preceding-sibling::listing | following-sibling::listing) in your case). At 12:23 PM 11/26/2003, you wrote: I thought the were going to be equal because they are part of the same context. Is there a way to compare the pair-wise unequal $unique-rooms to say an a sibling node with similar data? Depends on what you mean by "pair-wise", but yes. Is context part of the select statement? If I select //topics/topic/location am I in the location context, if so can I compare "." to //topics/place/room data? Sure -- it compares the string value of the context node to the string values of all the nodes in //topics/place/room (and tests true if any are the same). Notice however in your example that if you iterate over $unique-rooms, the context is no longer what it is outside the for-each - inside it, "." refers to each of the nodes in $unique-rooms as it is processed. The workaround for this is to bind your node of interest to a variable outside the for-each, and test against that: <xsl:variable name="here" select="."/>
<xsl:variable name="unique-rooms"
select="//topics/topic/location[not(. =
preceding::location)]" />
<xsl:for-each select="$unique-rooms">
<xsl:if test="../location = $here">
...Cheers, Wendell
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
|

Cart








