470,862 Members | 1,734 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,862 developers. It's quick & easy.

can't seem to figure out...

<to>John Doe</to>
<from>Jane Doe</from>
<subject>This is the subject</subject>

I'm trying to get the text within the multiple <paragraph> tags through
XSLT. If I have the following XSLT stylesheet:

<xsl:template match="/">
<p>To: <xsl:value-of select="to"/></p>
<p>From: <xsl:value-of select="from"/></p>
<p>Subject: <xsl:value-of select="subject"/></p>

If I want to cycle through the four paragraphs in the above, how would
I do that? I was thinking of using <xsl:for-each> but couldn't figure
out how to get the text.


Apr 10 '06 #1
1 1072
Your thought about xsl:for-each is one solution:
<xsl:for-each select="paragraph">
<xsl:value-of select="."/>

A more idiomatic solution would be to write a template for each of the
element types and let apply-template recursion take care of this iteration.

<xsl:template match="/">

<xsl:template match="to">
<p>To: <xsl:value-of select="."/></p>
<xsl:template match="from">
<p>From: <xsl:value-of select="."/></p>
<xsl:template match="subject">
<p>Subject: <xsl:value-of select="."/></p>
<xsl:template match="paragraph">
<p><xsl:value-of select="."/></p>

() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Apr 10 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Scott Wilkins | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.