i’ve a XML file which looks like:
<VersionHistory>
<Release Version="0.0.1" Date="27/1/2011">
<NewFeature>foo</NewFeature>
<BugFix>some text</BugFix>
<BugFix>some text</BugFix>
<BugFix Ticket="12004">some text</BugFix>
</Release>
<Release Version="0.0.2" Date="15/2/2011">
<NewFeature>foobar</NewFeature>
<BugFix>some more text</BugFix>
<BugFix>some more text</BugFix>
<BugFix Ticket="12001">some more text</BugFix>
</Release>
</VersionHistory>
Now my XSLT looks like this:
<xsl:template match="/">
<xsl:for-each select="VersionHistory/Release">
<xsl:sort select="@Version"/>
<ul>
<li>
<h3>New Feature<br/></h3>
<xsl:for-each select="NewFeature">
<ul>
<li>
<xsl:value-of select="NewFeature"/>
</li>
</ul>
</xsl:for-each>
</li>
<h3>
Fixed<br/>
</h3>
<xsl:for-each select="BugFix">
<ul>
<li>
<p>
<xsl:value-of select="BugFix"/>
</p>
</li>
</ul>
</xsl:for-each>
</li>
...
My problem is, that the 2nd for-each which goes through the BugFixes creates the amout of list items the xml contains of this element.. but i dont get the text which is between . Why?
How can i fix this?
this is not only for BugFix of course.. its for all this elements like BugFix, NewFeature (there are some more.. i haven’t list here)
greets
In your
for-eachyou selectNewFeature, then in thevalue-of, you are calling the value of a child-node calledNewFeature:Since
NewFeaturedoesn’t contain aNewFeaturenode, you see nothing.This would work (selecting the current node in the
for-eachloop):But a better option would be to use a template (which you should to with all of your
for-eachloops):