RE: [xsl] Converting embedded URLs int hot links via XSL

Subject: RE: [xsl] Converting embedded URLs int hot links via XSL
From: David.Pawson@xxxxxxxxxxx
Date: Mon, 19 Apr 2004 10:09:59 +0100
    The regxlib site - has a reasonable search capability - 
    search for https or just use this link:
    http://regxlib.com/Search.aspx?k=https

Thanks for that. Less sure it helps now... unless someone tells me
differently.

INput

 <vs>
<url>  Test url string:  'http://www.yahoo.com' and one more url
"https://www.yahoo.com";</url>

<url>http://www.yahoo.com</url>



part of xslt 2.0 stylesheet


<xsl:template match="/vs/url">
  <xsl:message>
  <xsl:value-of select="matches (.,
'(http|https|ftp)://((([a-z_0-9\-]+)+(([:]?)+([a-z_0-9\-]+))?)(@+)?)?(((((([
0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5]))).(((([0-1])?([0-9])?[0-9])
|(2[0-4][0-9])|(2[0-5][0-5]))).(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-
5][0-5])))\.(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5]))))|((([a-z
0-9\-])+.)+([a-z]{2}.[a-z]{2}|[a-z]{2,4})))(([:])(([1-9]{1}[0-9]{1,3})|([1-5
]{1}[0-9]{2,4})|(6[0-5]{2}[0-3][0-6])))?(/)?$')"/>
</xsl:message>
</xsl:template>



works fine on second usage, fails on first, since its not a match.

tokenize seems about right, to find the preceding and following strings,
which may then be used in substring before and after to extract the needed
string.

but saxon 7.9.1 seems not to match using

<xsl:template match="/vs/url">
  <xsl:message>
  <xsl:for-each select="tokenize (.,
'(http|https|ftp)://((([a-z_0-9\-]+)+(([:]?)+([a-z_0-9\-]+))?)(@+)?)?(((((([
0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5]))).(((([0-1])?([0-9])?[0-9])
|(2[0-4][0-9])|(2[0-5][0-5]))).(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-
5][0-5])))\.(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5]))))|((([a-z
0-9\-])+.)+([a-z]{2}.[a-z]{2}|[a-z]{2,4})))(([:])(([1-9]{1}[0-9]{1,3})|([1-5
]{1}[0-9]{2,4})|(6[0-5]{2}[0-3][0-6])))?(/)?$')">
    <xsl:value-of select="."/><xsl:text>
    ========
</xsl:text>
  </xsl:for-each>
</xsl:message>

</xsl:template>

only printing out the full string.

I'm also curious how I might add (escape) the single or double quotes prior
to the
url in the example.
http://www.w3.org/TR/xmlschema-2/#nt-Punctuation seems not to include these?


regards DaveP 



- 
DISCLAIMER: 

NOTICE: The information contained in this email and any attachments is 
confidential and may be privileged. If you are not the intended 
recipient you should not use, disclose, distribute or copy any of the 
content of it or of any attachment; you are requested to notify the 
sender immediately of your receipt of the email and then to delete it 
and any attachments from your system. 

RNIB endeavours to ensure that emails and any attachments generated by 
its staff are free from viruses or other contaminants. However, it 
cannot accept any responsibility for any  such which are transmitted.
We therefore recommend you scan all attachments. 

Please note that the statements and views expressed in this email and 
any attachments are those of the author and do not necessarily represent 
those of RNIB. 

RNIB Registered Charity Number: 226227 

Website: http://www.rnib.org.uk 

Current Thread