Applying Templates help
This is an open discussion with 10 replies, filed under XSLT.
Search
Try:
<ul><xsl:apply-templates select="tags/item" /></ul>
and
<xsl:template match="item"> <li><xsl:value-of select="." /></li> </xsl:template>
Well that removes the <li> element.
Try match="tags/item"
instead.
Well then that now spits out all the content that matches with tags/item, so I have the tags, the article itself, and so on.
If you have more elements that can be matched with tags/item try to be more specific in matching and selecting them (e.g. match="data/navigation/tags/item").
<xsl:template match="tags/item"> <li><xsl:value-of select="."/></li> </xsl:template> <ul><xsl:apply-templates select="tags/item" /></ul>
Should work otherwise.
or...
<xsl:template match="tags/item"> <li><xsl:value-of select="."/></li> </xsl:template>
What I meant... changed my code above. Thanks.
No worries. Thanks for the help. Appreciate it.
you can also do this Nick:
<xsl:template match="tags"> <xsl:for-each select="item" /> <li><xsl:value-of select="."/></li> </xsl:for-each> </xsl:template> <ul><xsl:apply-templates select="tags" /></ul>
But I think what you have now is probably better.
remember, though, if you have html in what you want to output, use
<xsl:copy-of select="* | text()" />
I think that should copy the html (*) and the text (text()).
never used that last bit of code before.
Create an account or sign in to comment.
Hi,
I know how to do the image thing when I am using apply-templates, but how do I do it when I want to display a list of tags.
Here is my XML:
My XSLT:
and
At the moment it is just displaying the one tag item.