This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: basic xpath question


Try this code..
Hope this helps..
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:output omit-xml-declaration="yes" media-type="html"/>
<xsl:template match="/">
<p>
<xsl:for-each select ="//section">
<xsl:choose>
<xsl:when test="./@id = 'url'">
<xsl:element name="a">
<xsl:attribute name="href"><xsl:value-of select="./@url"/></xsl:attribute>
<xsl:value-of select="."/></xsl:element>
</xsl:when>
<xsl:otherwise><xsl:value-of select="text()"/></xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</p>
</xsl:template>
</xsl:stylesheet>

Cheers
Vasu


From: "Hanlan, Dominic - Senior Developer" <dhanlan@icc.co.uk>
Reply-To: xsl-list@lists.mulberrytech.com
To: "'XSL-List@lists.mulberrytech.com'" <XSL-List@lists.mulberrytech.com>
Subject: [xsl] basic xpath question
Date: Thu, 20 Jun 2002 10:11:25 +0100

Hi,

 I have an xml document to be styled, if I have a construct such as

<section id="para">this is text <section id="url"
url="http://xx.yy.zz";>which is to be a link</section></section>

How do I, in xslt, recognise the "url" tag within the "para" tag, such that
I could ouput someting like

<p>this is test <a href="http://xx.yy.zz";>which is to be a link</a></p>

Regards




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



_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]