Connecting Tech Pros Worldwide Forums | Help | Site Map

external url link from an xml document and transforming it...

Newbie
 
Join Date: Jan 2007
Posts: 6
#1: Jan 2 '07
Hi,
I am really new to xml and this may sound dumb, but could someone please help me out by providing the code to linking to an external url from an xml file?

Right now I have the xml reading:
...<links><url_text>view larger</url_text> <url>www.domain.com/largerimages/sample.html</url>
</links>...

And I have the xslt document reading:

...<td><a>
<xsl:attribute name="HREF">http://<xsl:value-of select="url"/></xsl:attribute>
<xsl:value-of select="url_text"/></a></td>...

I have read that the following, above the <head> tag should read:
<xsl:template match="links"> but when I put links in the quotations, the whole file seems to disappear...

Thanks for anyone who can help...

Newbie
 
Join Date: Jan 2007
Posts: 4
#2: Jan 3 '07

re: external url link from an xml document and transforming it...


Hi
If you are asking for xml to html conversion,then this might help you.

Expand|Select|Wrap|Line Numbers
  1.   <xsl:template match="/">
  2.     <xsl:for-each select="links">
  3.      <td>      
  4.       <xsl:variable name="url" >
  5.        <xsl:value-of select="url" />
  6.       </xsl:variable>     
  7.       <a href="http://{$url}"><xsl:value-of select="url_text" /></a>
  8.     </td>
  9.     </xsl:for-each>
  10. </xsl:template>
  11.  
Newbie
 
Join Date: Jan 2007
Posts: 6
#3: Jan 3 '07

re: external url link from an xml document and transforming it...


Thank you! That worked perfectly!!!! I was missing a couple of things from my code. Thanks again!!!!

Quote:

Originally Posted by aparna8

Hi
If you are asking for xml to html conversion,then this might help you.

Expand|Select|Wrap|Line Numbers
  1.   <xsl:template match="/">
  2.     <xsl:for-each select="links">
  3.      <td>      
  4.       <xsl:variable name="url" >
  5.        <xsl:value-of select="url" />
  6.       </xsl:variable>     
  7.       <a href="http://{$url}"><xsl:value-of select="url_text" /></a>
  8.     </td>
  9.     </xsl:for-each>
  10. </xsl:template>
  11.  

Reply