xsl-list
[Top] [All Lists]

[xsl] RE: Finding the closest preceding element within the containing block

2012-05-18 14:44:53
If you're starting in d, I don't think there's any need to go all the way back 
up to ancestor a.  What about preceding-sibling::c[1] ?  I think that might do 
it.

Michele

-----Original Message-----
From: mlcook(_at_)Wabtec(_dot_)com [mailto:mlcook(_at_)Wabtec(_dot_)com] 
Sent: Friday, May 18, 2012 3:34 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Finding the closest preceding element within the containing block

Assume a document structure like the one below.

The "c" and "d" elements are at the same level inside of "b" which is inside of 
"a".

Currently, I can find the first "c" in the "b" that encloses "d".

But that is too far away.

I want to find the closest preceding "c" within the surrounding "b" when 
processing the template for element "d".

When executing the template for "d", my current path attempt is 
(ancestor::a[1]//c)[1]

But, if there is no preceding "c" in the "b" element, I'd like to detect that, 
and not find a "c" in any other "b".

If I use just "preceding::c", I might find a "c" in some other "b", which I 
don't want.

Thanks for any suggestions.

--Mike


<a>
   ...
   other elements
   ...
</a>
<a>
   ...
   other elements
   ...
</a>
<a>
   <b>
   ...
   </b>
   ...
   <b>
      ...
      <c/>   <---- My path gets this "c"
      ...
      <c/>
      ...
      <c/>   <---- I want this "c" when processing "d"
      ...
      <d/>
      ...
      <c/>
      ...
   </b>
   ...
   <b>
   ...
   </b>
</a>
<a>
   ...
   other elements
   ...
</a>
...


This email and any attachments are only for use by the intended recipient(s) 
and may contain legally privileged, confidential, proprietary or otherwise 
private information.  Any unauthorized use, reproduction, dissemination, 
distribution or other disclosure of the contents of this e-mail or its 
attachments is strictly prohibited.  If you have received this email in error, 
please notify the sender immediately and delete the original.



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--