- Joined
- Nov 25, 2011
- Messages
- 1
- Reaction score
- 0
Original XML:
<CategoryCodes>
<LocationCategory CodeDescription=""/>
<SegmentCategory CodeDescription=""/>
<HotelCategory CodeDescription="Apartment"/>
<GuestRoomInfo CodeDescription="The total number of rooms in your accommodation" Quantity="20"/>
</CategoryCodes>
1 ) If the atrribute value is CodeDescription change it to Code
2 ) If the value of Code is an empty string then remove the entire element.
Ex: LocationCategory
Required XML:
<CategoryCodes>
<HotelCategory Code="3"/>
<GuestRoomInfo Code="12" Quantity="20"/>
</CategoryCodes>
XSLT :
<xsl:template match="LocationCategory">
<LocationCategory>
<xsl:for-each select="@CodeDescription">
<xsl:variable name="var_code_value" select="."/>
<xsl:variable name="var_code_type" select="'LOC'"/>
<xsl:variable name="var_map_result" select="util:getCode($var_code_type,$var_code_value)"/>
<xsl:attribute name="Code">
<xsl:choose>
<xsl:when test="$var_map_result !=''">
<xsl:value-of select="$var_map_result"/>
</xsl:when>
<xsl
therwise>
<xsl:value-of select="$empty_string"/>
<!--<xsl:value-of select='0'/>-->
</xsl
therwise>
</xsl:choose>
</xsl:attribute>
</xsl:for-each>
<xsl:apply-templates select="@*|node()" />
</LocationCategory>
</xsl:template>
<xsl:template match="LocationCategory[@Code='']"/>
But result is different. So please help:adore:...
Thanx in advance :lol:
<CategoryCodes>
<LocationCategory CodeDescription=""/>
<SegmentCategory CodeDescription=""/>
<HotelCategory CodeDescription="Apartment"/>
<GuestRoomInfo CodeDescription="The total number of rooms in your accommodation" Quantity="20"/>
</CategoryCodes>
1 ) If the atrribute value is CodeDescription change it to Code
2 ) If the value of Code is an empty string then remove the entire element.
Ex: LocationCategory
Required XML:
<CategoryCodes>
<HotelCategory Code="3"/>
<GuestRoomInfo Code="12" Quantity="20"/>
</CategoryCodes>
XSLT :
<xsl:template match="LocationCategory">
<LocationCategory>
<xsl:for-each select="@CodeDescription">
<xsl:variable name="var_code_value" select="."/>
<xsl:variable name="var_code_type" select="'LOC'"/>
<xsl:variable name="var_map_result" select="util:getCode($var_code_type,$var_code_value)"/>
<xsl:attribute name="Code">
<xsl:choose>
<xsl:when test="$var_map_result !=''">
<xsl:value-of select="$var_map_result"/>
</xsl:when>
<xsl
<xsl:value-of select="$empty_string"/>
<!--<xsl:value-of select='0'/>-->
</xsl
</xsl:choose>
</xsl:attribute>
</xsl:for-each>
<xsl:apply-templates select="@*|node()" />
</LocationCategory>
</xsl:template>
<xsl:template match="LocationCategory[@Code='']"/>
But result is different. So please help:adore:...
Thanx in advance :lol: