xsl-list
[Top] [All Lists]

Re: [xsl] passing a regex matched substring to the result-document

2009-09-04 13:21:25
Manuel Souto Pico wrote:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="2.0"> <xsl:output method="xml" encoding="UTF-16" standalone="no" name="xml" indent="yes"/>
   <xsl:strip-space elements="*" />
   <xsl:template match="/">
<xsl:param name="COMMON"/> <xsl:for-each select="//file"> <xsl:variable name="srcfilename" select="base-uri(/)"/> <xsl:analyze-string select="$srcfilename" regex=".+/([^/]+)\.(XLF|xlf)">
               <xsl:matching-substring>
                   <xsl:variable name="COMMON" select="regex-group(1)"/>
                   <xsl:value-of select="$COMMON" /> <!-- Creating?? -->
               </xsl:matching-substring>
           </xsl:analyze-string>

I think you want
   <xsl:variable name="common">
<xsl:analyze-string select="$srcfilename" regex=".+/([^/]+)\.(XLF|xlf)">
               <xsl:matching-substring>
                   <xsl:value-of select="regex-group(1)"/>
               </xsl:matching-substring>
           </xsl:analyze-string>
   </xsl:variable>
to store the matched group in the variable named common.

Then you can use that variable in e.g.

                     <xsl:variable name="newfilename"
select="concat('output1/',$COMMON,_,@target-language,'.xlf')" />

  select="concat('output1/', $common, @target_language, '.xlf')"/>



--

        Martin Honnen
        http://msmvps.com/blogs/martin_honnen/

--~------------------------------------------------------------------
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>
--~--