Jump to content

XSLT not parsing the third record


akamathb

Recommended Posts

i have the below xslt, i/p and o/p.The problem is i am not able to parse the record.the xslt parses till the existence of first 2 property and returns back<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><xsl:output method="xml" indent="yes" encoding="utf-8"/><xsl:strip-space elements="*"/> <xsl:key name="k1" match="data/record" use="generate-id(preceding-sibling::record[normalize-space(@property)][1])"/><xsl:key name="k2" match="data/record[not(normalize-space(@property))]" use="generate-id(preceding-sibling::record[normalize-space(@property)][1])"/> <xsl:template match="data"> <defaultQuery> <xsl:for-each select="record"> <xsl:if test="@slno"> <subQuery> <xsl:attribute name="slno"><xsl:value-of select="@slno"/></xsl:attribute> <xsl:apply-templates select=". | key('k1', generate-id())" mode="group"/> </subQuery> </xsl:if> </xsl:for-each> </defaultQuery></xsl:template> <xsl:template match="record" mode="group"> <xsl:if test="@property !='' and @operator!= ''"> <condition> <property><xsl:value-of select="@property"/></property> <operator><xsl:value-of select="@operator"/></operator> <values> <xsl:apply-templates select=". | key('k2', generate-id())"/> </values> </condition> </xsl:if> </xsl:template><xsl:template match="data/record"> <value><xsl:value-of select="@value"/></value></xsl:template> </xsl:stylesheet>i/p:<data jsxid="jsxroot"><record jsxid="100" slno="1" property="DISTRIBUTION" operator="=" value="UNITED KINGDOM"/><record jsxid="101" property="BRAND OWNER" operator="Contains" value="HOOK"/><record jsxid="102" property="" operator="" value="500ML"/> <record jsxid="10111" property="BRAND OWNER11111111111" operator="Contains" value="HOOK"/></data>o/p<?xml version="1.0"?><defaultQuery><subQuery slno="1"><condition><property>DISTRIBUTION</property><operator>=</operator><values><value>UNITED KINGDOM</value></values></condition><condition><property>BRAND OWNER</property><operator>Contains</operator><values><value>HOOK</value><value>500ML</value></values></condition></subQuery></defaultQuery>expected o/p:<?xml version="1.0"?><defaultQuery><subQuery slno="1"><condition><property>DISTRIBUTION</property><operator>=</operator><values><value>UNITED KINGDOM</value></values></condition><condition><property>BRAND OWNER</property><operator>Contains</operator><values><value>HOOK</value><value>500ML</value></values></condition><condition><property>BRAND OWNER11111111111</property><operator>Contains</operator><values><value>HOOK</value></values></condition></subQuery></defaultQuery>pls help...thks in advance

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...