I have the following XSL file:
<xsl:stylesheet version="1.0" xmlns:xsl="http://ift.tt/tCZ8VR" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
<xsl:output method="xml" indent="yes" />
<xsl:template match="/EMPLOYEE">
<ROOT>
<xsl:for-each select="ADDRESSES">
<xsl:variable name="ADDRESSES" select="." />
<xsl:for-each select="RENTED_FLATS">
<xsl:variable name="RENTED_FLATS" select="." />
<xsl:element name="RENT_DATA">
<xsl:element name="ADDRESS">
<xsl:value-of select="$ADDRESSES/LINE1" />
</xsl:element>
<xsl:element name="FLOOR">
<xsl:value-of select="$RENTED_FLATS/FLOOR" />
</xsl:element>
</xsl:element>
</xsl:for-each>
</ROOT>
</xsl:template>
</xsl:stylesheet>
The logic is simple: given an input file of ADDRESSES, I want to get the Renting data of each address.
The problem with my implementation is that if there are no nodes "RENTED_FLATS" then it won't enter inside the loop, but I require that, if there's an address without RENTED_FLATS, it still must appear in the output with the element FLOOR empty.
How can I achieve that in XSL?
Thanks and kind regards
No comments:
Post a Comment