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


Hi Dominic,

> 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>

The simplest way would be to use templates that match section elements
with different values for their id attributes:

<xsl:template match="section[@id = 'para']">
  <p><xsl:apply-templates /></p>
</xsl:template>

<xsl:template match="section[@id = 'url']">
  <a href="{@url}"><xsl:apply-templates /></a>
</xsl:template>

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 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]