Subject: Re: [xsl] finding whether starts-with or not prob From: Oleg Tkachenko <olegt@xxxxxxxxxxxxx> Date: Wed, 22 May 2002 11:37:01 +0200 |
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 =)This end tag is probably a typo, isn't it? Get rid of this and the stylesheet will work.
XSL-FILE:(Part of it) <xsl:apply-templates select="Document/Information" />
<xsl:template match="Information">
</xsl:if>
<xsl:if test="@SignStatus='Open'">More correctly, *the context node* is an "Information" element.
<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? -->
And this end tag doesn't have counterpart start tag, which <xsl:if> do you want to close here?<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>
</xsl:template>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.
<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? -->
</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>
<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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] finding whether starts-with o, Jarkko . Moilanen | Thread | Re: [xsl] finding whether starts-wi, Jarkko . Moilanen |
Re: [xsl] Grouping question, Jeni Tennison | Date | Re: [xsl] XHTML+XSL --> XSL, Antonio Fiol |
Month |