I'm having a XSLT problem.

I am reading from one xml sheet and creating another using XSLT. The final transformed XML has an element <Recreations> that contains <Recreation> elements. I am using <xsl:for-each> to create the <Recreation> elements. So my xslt looks something like this:

<Recreations>
<xsl:for-each select="MyItems">
<xsl:if select="cust:isThisARecreation(@Description)>
<Recreation>
<xsl:value-of select="@Description">
</Recreation>
</xsl:if>
</xsl:for-each>
</Recreations>

So: isThisARecreation function is a custom Java function. The <Recreations> element could contain zero to many <Recreation> elements. If there are no <Recreation> elements then I have to remove the <Recreations> element.

I have to go through the loop to know if there are Recreation elements. If there aren't I don't need it's parent element. Anyone have any ideas on how I might do this?

Thanks,
Ben

please show the orignal xml file

and use not for-each think in template

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.