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

Re: Determining if an element exists within any tag of

Subject: Re: Determining if an element exists within any tag of a specified name...
From: Michael Leahy <mgleahy@xxxxxxxxxxxxxxxx>
Date: Thu, 06 Jun 2002 16:14:39 -0400
xsl test element exists
Thanks for the suggestion. After a little playing around, I was also able to get something else that seems to work. I was able to replace:

<xsl:if test="..[($any$ attr/attrtype != '')]">

with:

<xsl:if test="current()[../*/attrtype[. != '')]">

That seems to have done the trick - for that part of the code.

Now I'm stuck where the following code is used to list a number of hotlinks:

  <xsl:for-each select="metadata/idinfo/citation/citeinfo/onlink [. != '']">
    <A><xsl:attribute name="HREF"><xsl:value-of select="."/>
    </xsl:attribute>View Map
    </A>
    <xsl:if test="current()[not(end())]">, </xsl:if>
    </xsl:for-each>


The second last line checks to see if the current "onlink" is the last one, and if not, add a comma, then the loop continues. However, the end function is another invalid command, and IE6 gives the following error:


'end' is not a valid XSLT or XPath function. current()[not(-->end()<--)]

is there an easy way to check if the current element is the last one?

Mike

At 08:26 PM 6/6/2002 +0200, you wrote:
Hello Michael,

I must say that I don't know nothing about WD-XSL. I only can guess, what the old version does and how you can replace it with the new one:

<xsl:for-each select="attr[attrlabl != '']">
  <tr>
    <td>
      <font color="#000000" face="Arial, Helvetica, sans-serif" size="2">
        <xsl:value-of select="attrtype"/>
        <xsl:if test="not(normalize-space(attrtype))">---</xsl:if>
      </font>
    </td>
    <td>
      <font color="#000000" face="Arial, Helvetica, sans-serif" size="2">
        <xsl:value-of select="atoutwid"/>
        <xsl:if test="not(normalize-space(atoutwid))">---</xsl:if>
      </font>
    </td>
  </tr>
</xsl:for-each>

Does this do the job? It should do the same, if you have only one 'attrtype' or onr 'atoutwid'. If there are more of them, the code must be changed a bit. Ask for it ;-)

Regards,

Joerg


<xsl:for-each select="attr[attrlabl != '']">
<tr>
....
<xsl:choose> <!-- Write the attrtype property if it is defined. -->
<xsl:when test="current()[(attrtype !='')]"> <xsl:for-each select="attrtype"> <td><font color="#000000" face="Arial, Helvetica, sans-serif" size="2"><xsl:value-of select="."/></font></td>
</xsl:for-each> </xsl:when> <xsl:otherwise>
<!-- If the property was not defined, yet the table has the heading "Type" because some other
attribute in the currently selected tag ("current()") has this property defined, then write out
three dashes in the table cell-->
<xsl:if test="..[($any$ attr/attrtype != '')]"> <td><font color="#000000" face="Arial, Helvetica, sans-serif" size="2">---
</font></td>
</xsl:if> </xsl:otherwise> </xsl:choose>
<!-- Write the atoutwid property-->
<xsl:choose> <xsl:when test="current()[(atoutwid != '')]"> <xsl:for-each select="atoutwid"> <td><font color="#000000" face="Arial, Helvetica, sans-serif" size="2"><xsl:value-of select="."/></font></td>
</xsl:for-each> </xsl:when> <xsl:otherwise> <xsl:if test="..[($any$ attr/atoutwid != '')]"> <td><font color="#000000" face="Arial, Helvetica, sans-serif" size="2">---
</font></td>
</xsl:if> </xsl:otherwise> </xsl:choose>
....code repeated for all required properties


  </tr>
</xsl:for-each>


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list


----------------------------------------------------------------------------------

Michael Leahy, Computing and Data Resource Assistant
Mapping, Analysis and Design, ES2-163C
Faculty of Environmental Studies
University of Waterloo
Waterloo, Ontario, N2L 3G1.
E-mail: mgleahy@xxxxxxxxxxxxxxxx
Phone: 519-888-4567 ext. 6727
Fax: 519-888-4325
----------------------------------------------------------------------------------




XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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