|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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>
![]() 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> Thanks for reading! |
|
#2
|
|||
|
|||
|
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"> <xsl utput 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 |
|
#3
|
|||
|
|||
|
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"> <xsl utput 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 |
|
#4
|
|||
|
|||
|
Thanks Niha, the code works well!
Cheers ![]() |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > XSL - search string, add anchor tags |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|