xsl-list
[Top] [All Lists]

Re: [xsl] How to code with relative context: "if the next node <ns3:ddd></ns3:ddd> is not empty then ....."

2009-11-05 13:01:48
Ben Stover wrote:
I would like to copy something to the target XML doc context (!) depending from 
the value of a node on the same level.

It should all look similar to the following pseudo code:

...assume we are on level/inside <aaa><bbb><ccc>
<xs:if <ddd>...</ddd> contains a non-whitespace value then>
  <mytext>yes value found<mytext>
<xs:else>
  <myothertext>no value found</myothertext>
</xs:if>
...
</ccc>...</bbb>....</aaa>

How can I code this with XSLT ?

Again: If possible the condition should be context dependent. I don't want to 
code
the full XPath  /aaa/bbb/ccc/ddd in the "if" clause.
Instead the XPath expression should be relative to the current position

Well if you have
  <xsl:template match="ccc">
or maybe
  <xsl:template match="aaa/bbb/ccc">
then in that template you can certainly use
    <xsl:choose>
      <xsl:when test="ddd[normalizes-space()]">
        <mytext>yes value found<mytext>
      </xsl:when>
      <xsl:otherwise>
        <myothertext>no value found</myothertext>
      </xsl:otherwise>
    </xsl:choose>

--

        Martin Honnen
        http://msmvps.com/blogs/martin_honnen/

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