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

Re: finding whether starts-with or not prob

Subject: Re: finding whether starts-with or not prob
From: Oleg Tkachenko <olegt@xxxxxxxxxxxxx>
Date: Wed, 22 May 2002 11:37:01 +0200
xsl if test starts with
Jarkko.Moilanen@xxxxxx wrote:

I have a small prob. I'm trying to apply a template inside another one. The tempalte is supposed to solve whether the <DocType> value is order or something else and depending from the result do something in both cases. I have been trying to solve whats wrong, but I can't find the reason why it is not working. I know this is not the best solution for this case, to find out the content of the element, but hey... who's perfect =)

XSL-FILE:(Part of it) <xsl:apply-templates select="Document/Information" />
<xsl:template match="Information">
</xsl:if>
This end tag is probably a typo, isn't it? Get rid of this and the stylesheet will work.

<xsl:if test="@SignStatus='Open'">
<td bgcolor="#C4DAFE" width="50">
<p ID="SignStatus"><font size="-1">
<xsl:value-of select="@SignStatus" /> </font>
</p></td>
</xsl:if>
<!-- SINCE I AM "INSIDE" INFORMATION ELEMENT; I CAN CALL DIRECTLY
THE DOCTYPE TEMPLATE, RIGHT? -->
More correctly, *the context node* is an "Information" element.

		<xsl:apply-templates select="DocType" />
		
		<td bgcolor="#C4DAFE" width="124">
                <p ID="Sender"><font size="-2">
		<xsl:value-of select="Sender" /></font>
		</p></td>
</xsl:if>
And this end tag doesn't have counterpart start tag, which <xsl:if> do you want to close here?

</xsl:template>

<xsl:template match="DocType">
		<xsl:if test="not(starts-with(., 'order'))">
			<td bgcolor="#C4DAFE" width="50">
                	<p ID="type"><font size="-2">
			<xsl:value-of select="." /></font>
                   <!-- ISNT THE DOT POINTING TO THE DOCTYPE ELEMENTS CONTENT? -->
Not exactly. "." is a short form of self::node(), which means the context node itself, which is DocType element in the place and <xsl:value-of> instruction is outputting string value of the first node selected by expression in "select" attribute, so you can say <xsl:value-of select="." /> is outputting string value of the context node.

      			</p></td>
		</xsl:if>
		<xsl:if test="starts-with(., 'order')">
			<td bgcolor="#C4DAFE" width="50">
               		<p ID="type"><font size="-2"><b>
			<xsl:value-of select="." /></b></font>
			</p></td>
		</xsl:if>		
</xsl:template>

btw, isn't it simpler to use a choice here?


  <xsl:template match="DocType">
    <td bgcolor="#C4DAFE" width="50">
      <p ID="type">
        <font size="-2">
          <xsl:choose>
            <xsl:when test="starts-with(., 'order')">
              <b>
                <xsl:value-of select="."/>
              </b>
            </xsl:when>
            <xsl:otherwise>
              <xsl:value-of select="."/>
            </xsl:otherwise>
          </xsl:choose>
        </font>
      </p>
    </td>
   </xsl:template>

--
Oleg Tkachenko
Multiconn International, Israel


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.