On 5/13/05, Micah Dubinko <micah(_at_)dubinko(_dot_)info> wrote:
Thanks,
I've used tokenize, and I like it. But it seems to only work where you
can throw away the delimiters.
Ex. "a b c" --> "a", "b", "c" (with the spaces gone)
In this case, what I need is
"3.04in" --> "3.04", "in"
So I'd need a regex that hits in the right spot, but matches zero
characters. I don't think lookaheads are in the spec. At least I haven't
found them. Neither are subexpressions that I can tell.
I still have a feeling that XSLT2 offers some elegant way to do this, at
least more elegant than my current 11-line <xsl:choose> construction. Am
I off-key?
.micah
Using FXSL one would write (both in XSLT 1.0 and XSLT 2.0) something like this:
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:f="http://fxsl.sf.net/"
xmlns:myController="f:myController"
xmlns:x="f:myTest"
exclude-result-prefixes="f myController x"
<xsl:import href="../f/strSpan.xsl"/>
<!-- To be applied on csstext.xml -->
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<myController:myController/>
<xsl:variable name="x:st" select="document('')/*"/>
<xsl:template match="/">
<xsl:call-template name="strSpan">
<xsl:with-param name="pStr" select="string(/*)"/>
<xsl:with-param name="pController"
select="$x:st/myController:*[1]"/>
<xsl:with-param name="pContollerParam"
select="'0123456789.'"/>
<xsl:with-param name="pElementName1" select="'value'"/>
<xsl:with-param name="pElementName2" select="'unit'"/>
</xsl:call-template>
</xsl:template>
<xsl:template match="myController:*" mode="f:FXSL">
<xsl:param name="pChar"/>
<xsl:param name="pParams"/>
<xsl:if test="contains($pParams, $pChar)">1</xsl:if>
</xsl:template>
</xsl:stylesheet>
When this transformation is applied on the following source xml document:
<csstext>5.5in</csstext>
the result is:
<value>5.5</value>
<unit>in</unit>
I haven't re-writen the "strSpan" template as an xsl:function simply
because I need to decide on a clear convention how to represents the
results of a function, which returns more than one sequence.
Cheers,
Dimitre Novatchev
--~------------------------------------------------------------------
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>
--~--