XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old August 13th, 2003, 11:16 AM
polymorph polymorph is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 2 polymorph User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
XSL - search string, add anchor tags

Hello all,

I have an XSL document with a function that loops through XML nodes and spits out the data - my problem is that any links are parsed as plain text and don't work in the browser. My (stripped down to focus on the loop) XSL doc looks like this:
Code:
<xsl:for-each select="root/comment">
        <xsl:value-of select="message"/>
</xsl:for-each>
I've tried enclosing the data in CDATA tags and using disable-output-escaping="yes" but to no avail

The XML looks like this after I wrote a PHP function to strip the href tags from the text string and return a vB Code style link back, i.e.
Code:
<comment>
	<message>This is some text before a link [a]http://www.someURL.co.uk[/a] and this is trailing text</message>
</comment>
So how can I use XSLT to parse the string and create valid link code that the browser can read? I'm not familiar with XSLT substring functions as I assume this will sort out my problem as long as it can find the [a][/a] tags and make the link from the text found between them.

Thanks for reading!

Reply With Quote
  #2  
Old August 14th, 2003, 04:44 AM
nihaarika2002 nihaarika2002 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 49 nihaarika2002 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
hope this give some idea

hi
this might give u an idea....

i still working for suitable solution though
meanwhile i hope this may help u



if ur xml this format :::



<?xml version="1.0" encoding="UTF-8"?>
<root>
<comment>
<message>This is some text before a link 1 <ulink url="http://www.yahoo.com/" >http://www.yahoo.com/</ulink> and this is trailing text</message>
<message>This is some text before a link 2 <ulink url="http://www.hotmail.com/" >http://www.hotmail.com/</ulink> and this is trailing text</message>
<message>This is some text before a link 3<ulink url="http://www.google.com/" >http://www.google.com/</ulink> and this is trailing text</message>
</comment>
</root>



----

u can do xsl :: like this

----

<?xml version="1.0"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xslutput method="html" indent="yes" encoding="utf-8" omit-xml-declaration="yes" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>


<xsl:template match="root">
<xsl:for-each select="//comment/message">

<xsl:apply-templates />
<br/>

</xsl:for-each>

</xsl:template>


<xsl:template match="/root/comment/message/ulink">


<A class="headbold" HREF="{@url}">

<xsl:apply-templates/>

</A>

</xsl:template>
</xsl:stylesheet>






=====
this is exactly does what u r trying to do now...

regards
niha

Reply With Quote
  #3  
Old August 14th, 2003, 04:54 AM
nihaarika2002 nihaarika2002 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 49 nihaarika2002 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
can u c this latest version

hi

i think it can be done only if u keep that url in a tag
<a>

instaed [a]

====

xml


<?xml version="1.0" encoding="UTF-8"?>
<root>
<comment>
<message>This is some text before a link 1 <a>http://www.yahoo.co.uk</a> and this is trailing text</message>
<message>This is some text before a link 2 <a>http://www.someURL.co.uk</a> and this is trailing text</message>
<message>This is some text before a link 3 <a>http://www.someURL.co.uk</a> and this is trailing text</message>
</comment>
</root>



===

xsl program

<?xml version="1.0"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xslutput method="html" indent="yes" encoding="utf-8" omit-xml-declaration="yes" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>


<xsl:template match="root">
<xsl:for-each select="//comment/message">

<xsl:apply-templates />
<br/>

</xsl:for-each>

</xsl:template>


<xsl:template match="/root/comment/message/a">


<A HREF="{.}">

<xsl:apply-templates/>

</A>

</xsl:template>
</xsl:stylesheet>


hope this helps...
regards
niha

Reply With Quote
  #4  
Old August 15th, 2003, 07:23 AM
polymorph polymorph is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 2 polymorph User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks Niha, the code works well!

Cheers

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > XSL - search string, add anchor tags


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway