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

RE: Identifing links in text

Subject: RE: Identifing links in text
From: "Andrew Welch" <awelch@xxxxxxxxxxxxxxx>
Date: Thu, 6 Jun 2002 09:21:58 +0100
regexp find links in text
Hi Joerg,

Joerg wrote:

>Hi Andrew,
>
>of course, my template can be shortened a bit. But your template
doesn't 
>do what was required - or where is your recursiion ;-)

Ok, so it would only work for one url per text() node, but I still think
its pretty neat

cheers
andrew



Joerg

Andrew Welch wrote:
>>I need some way to identify a link like statement in a tagged piece
>>of text.
> 
> 
> I know Joerg has already given you a solution, but I thought I would
> offer a slightly smaller and simpler template that will do trick:
> 
> <xsl:template match="text()">
>   <xsl:choose>
>   <xsl:when test="contains(.,'http://')">
>     <xsl:variable name="theURL"
>
select="concat('http://',substring-before(substring-after(.,'http://'),'
> '))"/>
>     <xsl:value-of select="substring-before(.,$theURL)"/>
>     <a href="{$theURL}"><xsl:value-of select="$theURL"/></a>
>     <xsl:value-of select="substring-after(.,$theURL)"/>
>   </xsl:when>
>   <xsl:otherwise>
>     <xsl:value-of select="."/>
>   </xsl:otherwise>
>   </xsl:choose>
> </xsl:template>
> 
> This checks to see if the text() content of the node contains
'http://'.
> If it doesnt it just outputs the text as usual, but if it does then it
> separates the string into three bits (before url, url, after url) and
> outputs them with the url marked up into a link.
> 
> text manipulation is always hard with xslt but it can be good to mess
> around with the string handling functions to get what you need
> 
> cheers
> andrew
> 
> 
> 
> 
> -----Original Message-----
> From: Charles Knell [mailto:cknell@xxxxxxxxxx]
> Sent: 04 June 2002 18:37
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re:  Identifing links in text
> 
> 
> ---- Raimund Kammering <Raimund.Kammering@xxxxxxx> wrote:
> 
>>Hallo Everybody,
>>
>>I need some way to identify a link like statement in a tagged piece
>>of
>>text. To make it more clear
>>here is a small sample the XML code migth look like:
>>
>><entry>
>> <keyword>Info</keyword>
>> <text>Some amount of plain text. But inside may appear a
>>statement like this: http://www.some-server.com and this shall
>>be shown as a usual (blue) link in a browser.</text>
>><entry>
> 
> 
> You've identified one of XSLT's weaknesses. You will most likely have
> to write an extension function incorporating regular expression
> processing
> so you will be able to find and wrap the links with the <a
href=""></a>
> tags.
> 
> I believe that most processors provide a means of extending xsl's
> built-in
> functions. I know that you can write JavaScript extensions for MSXML
> (because I've done it) and that Oracle's processor supports extension
> functions written in Java (because I've researched, but not written
> any).
> 
> It is only with the most recent version of Java (J2SE 1.4 ?) that a
> standard
> API for regular expression processing has been included. JavaScript
has
> very good regular expression capabilities, so if you are using MSXML,
> you will probably not have too much trouble in writing the function.
> 
> If you're willing to "think outside the box" for this, you could
easily
> write a Perl script to pre-process this file before it gets sent to
the
> XSL processor.



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list





---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.350 / Virus Database: 196 - Release Date: 17/04/2002
 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.350 / Virus Database: 196 - Release Date: 17/04/2002
 

 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.