[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] need variable in analyze-string regex
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|