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

RE: XML attribute value to pattern match of the replac

Subject: RE: XML attribute value to pattern match of the replace function
From: "Selvaganesh" <selvaganesh_t@xxxxxxxxxxxxxx>
Date: Mon, 22 Feb 2010 16:52:12 +0530
RE:  XML attribute value to pattern match of the replac
Thanks for the help. 

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

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), ')'),
'&lt;cite&gt;$1&lt;/cite&gt;')"/>


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

<xsl:element name="caseref">
<xsl:analyze-string select="." regex="({@party1}.*?{@party2})">
     <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>

Sample input:

<caseref party1="President of South Africa" party2="Modderklip Boerdery
(Pty) Ltd">President of South Africa v Modderklip Boerdery (Pty)
Ltd</caseref>

But the replacement looks as if you want to insert a 'cite' element so 
using analyze-string instead of replace might be what you really want. 
So instead of the value-of use e.g.

   <xsl:analyze-string select="." regex="({@party1}.*?{@party2})">
     <xsl:matching-substring>
        <cite>
          <xsl:value-of select="regex-group(1)"/>
        </cite>
     </xsl:matching-substring>
     <xsl:non-matching-substring>
        <xsl:value-of select="."/>
     </xsl:non-matching-substring>
   </xsl:analyze-string>

The above is untested.


-- 

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



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.

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.