[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

need variable in analyze-string regex

Subject: need variable in analyze-string regex
From: John Sharp <jsharp@xxxxxx>
Date: Fri, 06 Jun 2003 10:24:50 -0500
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.