Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 19th, 2009, 01:40 PM
Registered User
 
Join Date: May 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default regular expression in replace()

For solution of the task with search and keyword replacement under the dictionary it is necessary to take advantage of following regular expression which selects a word (for example JAVA) having spaces on both sides:
Code:
(?<=\s*)JAVA(?=\s*)
It is impossible to register this expression in function analyze-string, gives out an error. Prompt, please, in what a problem and how it can be solved?
Code:
<xsl:analyze-string select="replace($text, concat('((?<=\s*)', $keyphrase, '(?=\s*))'), '[$1]', 'i')" flags="i" regex="\[(.*?)\]"> 
    <xsl:matching-substring>
        <xsl:element name="a">
            <xsl:attribute name="href" select="$href" />
            <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>
 
Old May 20th, 2009, 02:07 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

I'm sorry, I don't know Java regular expressions well enough to know what this one is intended to do, but I can tell you that it is not a legal XPath expression. You will find a good description of what is allowed in XPath regular expressions in my book - there is a chapter devoted to the subject.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old May 20th, 2009, 04:22 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

The book title is in my signature, and more details are here:

http://www.wrox.com/WileyCDA/WroxTit...470192747.html

Regular expressions are covered in Chapter 14. (You can buy the chapter online if you want).
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Regular Expression Help Please rstelma ASP.NET 1.0 and 1.1 Professional 0 January 2nd, 2008 07:01 PM
Regular Expression in C++ praveenholal C++ Programming 1 March 4th, 2007 01:18 AM
Regular Expressions and Replace Function ttbhandari VBScript 4 May 20th, 2005 05:10 PM
regular expression vohra_vikas2004 ADO.NET 3 November 18th, 2004 09:59 PM
help in regular expression diby Beginning PHP 1 September 17th, 2003 12:25 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.