On 30-3-2014 3:07, Dimitre Novatchev wrote:
I am glad that you will be happy: :)
Yes I am, and a bit blushing now ;)
Do you see any <xsl:choose> or <xsl:if> in the code below?
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:param name="left" select="3"/>
<xsl:param name="right" select="2"/>
<xsl:param name="operator" select="'*'" />
<xsl:template match="/">
<xsl:call-template name="calculator2"/>
</xsl:template>
<xsl:template name="calculator2">
<xsl:apply-templates select="self::node()[$operator = '*']" mode="mult"/>
<xsl:apply-templates select="self::node()[$operator = '+']" mode="add"/>
<xsl:apply-templates select=
"self::node()[not($operator = '+') and not($operator = '*') ]"
mode="error"/>
</xsl:template>
So simple! I hate it that I didn't think of that myself :). Creative
programming, and still elegant, very nice!
And in the event that there is no initial node (which only happens in
2.0+), you can always create one.
I assume you would come up with similarly simple solutions to solve for
instance searching for a string in a string and returning its positions
or occurrences. At the very minimal, I thing you would need something
like codepoints-to-string and its reverse, or substring, or a variant
thereof, which would probably be enough to add that machinery.
Cheers & thanks,
Abel Braaksma
Exselt XSLT 3.0 processor
http://exselt.net
--~------------------------------------------------------------------
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>
--~--