xsl-list
[Top] [All Lists]

RE: [xsl] XML attribute value to pattern match of the replace function

2010-02-22 06:02:12
Thanks Martin.

-----Original Message-----
From: Martin Honnen [mailto:Martin(_dot_)Honnen(_at_)gmx(_dot_)de] 
Sent: Monday, February 22, 2010 4:54 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] XML attribute value to pattern match of the replace
function

Selvaganesh wrote:


You need to concat the attribute values e.g.
  select="replace(., concat('(', @party1, '.*?', @party2, ')'), 
'<cite>$1</cite>')"

In case the xml content appear parenthesis () does not process the replace
function can u suggest any other way.

Also I have tried below way, but does not working.

select="(concat('(', string(@party1), '.*?', string(@party2), ')'),
'<cite>$1</cite>')"/>


Also I have tried the analyze-string method but it was working fine but
above issue was repeated. 

Use the function defined here
http://www.xsltfunctions.com/xsl/functx_escape-for-regex.html
to escape the attribute values e.g.

<xsl:element name="caseref">
<xsl:analyze-string select="." 
regex="({functx:escape-for-regex(@party1)}.*?{functx:escape-for-regex(@party
2)})">
      <xsl:matching-substring>
         <xsl:element name="casetitle">
           <xsl:value-of select="regex-group(1)"/>
         </xsl:element>
      </xsl:matching-substring>
      <xsl:non-matching-substring>
         <xsl:value-of select="."/>
      </xsl:non-matching-substring>
    </xsl:analyze-string>
</xsl:element>
</xsl:template>

-- 

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



Confidentiality Notice:  This transmittal is a confidential communication.  If 
you are not the intended recipient, you are hereby notified that you have 
received this transmittal in error and that any review, dissemination, 
distribution or copying of this transmittal is strictly prohibited.  If you 
have received this communication in error, please notify this office 
immediately by reply and immediately delete this message and all of its 
attachments, if any.


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