|
Subject: [xsl] need variable in analyze-string regex From: John Sharp <jsharp@xxxxxx> Date: Fri, 06 Jun 2003 10:24:50 -0500 |
Hello, I recently started with XSLT and got a couple of
questions...
I appear to need variables in the style of:-
<xsl:analyze-string select="$pattern" regex="$regex">
becuse I need to apply different regexs to the same input.
The number of regexs to process are defined in elsewhere.
(I realize this is not directly supported).
<!-- sample regex file -->
<RegexList>
<Regex>.*</Regex>
<Regex>^[0-9]+</Regex>
I thought about generating the xsl from the regex.xml as
that way the regex would be strings, any better ideas ?
XPath 2.0 will support regexs, when is the first XPath 2.0
engine likely to be available ?
One other list member outlined a method of using the java Perl
regex, by calling Java from XSL. Was this work ever completed ?
My original problem XSL
<xsl:template match="/">
<!-- write XMLoutput root tag -->
<PatternGeneratedTable>
<JazzPatternSet>
<!-- cycle through our list of regexes -->
<xsl:for-each select="$patternRegex//PatLstSel">
<xsl:variable name="regex" select="."/>
<xsl:element name="Test">
<xsl:value-of select="./parent::Test/@Name"/>
</xsl:element>
<Group>
<!-- cycle through PatternNames, apply regex to each -->
<xsl:for-each select="$patternList//Pattern">
<!-- cache patternName -->
<xsl:variable name="pattern" select="current()/."/>
<xsl:analyze-string select="$pattern" regex="$regex">
<xsl:matching-substring>
<!-- we have a match -->
<!-- write out the cached patternName -->
<PatternName><xsl:value-of select="$pattern"/></PatternName>
</xsl:matching-substring>
<xsl:non-matching-substring/>
</xsl:analyze-string>
</xsl:for-each>
</Group>
</xsl:for-each>
<!-- close XMLoutput root tag -->
</JazzPatternSet>
</PatternGeneratedTable>
</xsl:template>
Thanks, John.
--
Texas Instruments Inc Product Development tel:214 480 4253
PO BOX 660199 MS: 8645 FORE/A-3101 fax:214 480 4401
12500 TI Boulevard Dallas, TX 75266-0199
nawk nawk, Who's there ? Aho, Weinberger and Kerninghan.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] MIME Digest?, Arnaud Vandyck | Thread | Re: [xsl] need variable in analyze-, David Carlisle |
| RE: [xsl] XSL and DOM, Joseph Kesselman | Date | [xsl] Must be a better way to write, Simon . Fairey |
| Month |