This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: finding whether starts-with or not prob
Lainaus Oleg Tkachenko <olegt@multiconn.com>:
> Jarkko.Moilanen@uta.fi 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.
>
In the larger context it is needed.
> > <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?
The samehere, in the larger contxt it is needed.
>
> > </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.
>
Thanks.
> > </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>
This is how I do it now, since I didn't manage to do it the way
discussed here.
Cheers
Jarkko
>
> --
> Oleg Tkachenko
> Multiconn International, Israel
>
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
>
>
******************************************************************
Jarkko Moilanen *You are wise, witty, and wonderful, *
Researcher/ ITCM *but you spend too much time *
jm60697@uta.fi *reading this sort of trash. *
www.uta.fi/~jm60697 * *
GSM: +358 50 3766 927 * *
******************************************************************
* ITCM | Information Technology and Crisis Management *
* http://www.itcm.org *
******************************************************************
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list