xsl-list
[Top] [All Lists]

RE: [xsl] Return text contents of most recent non-null sibling.

2012-08-15 08:30:11

Thanks Michael.

The important distinction you have made, and that I had missed, is between "an 
element that exists" and "an element that exists and is not null".

I've fitted this into my implementation (not your XPath 2) and can now see it 
working.

Where I previously had : 
<test heading="{preceding-sibling::node()[column[1]][1]/column[1]}" 
type="absent" value="{column[3]}" />

I now have :
<test heading="{preceding-sibling::node()[column[1] != ''][1]/column[1]}" 
type="absent" value="{column[3]}" />

And that works.


However .....

Now I come to incorporate what I've learnt into my real problem I find that I 
asked the wrong question....


Another will be along in a moment, under a new Subject.

Appreciatively,
Richard.



________________________________________
From: Michael Müller-Hillebrand [mmh(_at_)cap-studio(_dot_)de]
Sent: 14 August 2012 17:51
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] Return text contents of most recent non-null sibling.

Hi Richard,

Your predicate just checks whether any of the preceding-sibling rows have a 
first column child, you also have to check whether it is empty or not. How 
about this, if you can use XPath 2:

<xsl:template match="row">
   <xsl:variable name="heading" select="column[@column eq '1']" />
   <item row="{@row}" name="{
      if ($heading != '')
      then $heading
      else preceding-sibling::row[column[@column eq '1'] != 
''][1]/column[@column eq '1']
     }" value="{column[@column eq '3']}" />
</xsl:template>

You see I also used the @column attribute to locate the correct cell but that 
might be unnecessary.

Of course it would be even better to create a function like 
my:GetCurrentHeading() to encapsulate the if-then-else stuff.

HTH,

- Michael


Am 14.08.2012 um 18:03 schrieb Kerry, Richard:

<xsl:otherwise>
<test heading="{preceding-sibling::node()[column[1]][1]/column[1]}" 
type="absent" value="{column[3]}" />
</xsl:otherwise>

--
_______________________________________________________________
Michael Müller-Hillebrand: Dokumentations-Technologie
Adobe Certified Expert, FrameMaker
Lösungen und Training, FrameScript, XML/XSL, Unicode
Blog: http://cap-studio.de/ - Tel. +49 (9131) 28747





--~------------------------------------------------------------------
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>
--~--


<Prev in Thread] Current Thread [Next in Thread>