0

Hey all,

I want to access for each coverage, for each vehicle a combined node of ABC and EFG, I wanna show. I know that I ll have to concat the values of CoverageLimit but How can I acccess two nodes at a time.

Thankx in advance.

Output:

Vehicle 1: ABC Upto 50,000/Upto 50,000

Vehicle 2: ABC Upto 50,000/Upto 50,000

<Policy>
<Vehicle id="v1">
<Coverage>
<CoverageName>ABC</CoverageName>
<CoverageLimit>Upto 50,000</CoverageLimit>
<CoverageAmount>100</CoverageAmount>
<Indicator>TL</Indicator>
</Coverage>
<Coverage>
<CoverageName>EFG</CoverageName>
<CoverageLimit>Upto 50,000</CoverageLimit>
<CoverageAmount>50</CoverageAmount>
<Indicator></Indicator>
</Coverage>
<Coverage>
<CoverageName>HIJ</CoverageName>
<CoverageLimit>Upto 10,000</CoverageLimit>
<CoverageAmount>20</CoverageAmount>
<Indicator></Indicator>
</Coverage>
<Coverage>
<CoverageName>KLM</CoverageName>
<CoverageLimit>Upto 100,000</CoverageLimit>
<CoverageAmount>10</CoverageAmount>
<Indicator>TL</Indicator>
</Coverage>
</Vehicle>
<Vehicle id="v2">
<Coverage>
<CoverageName>ABC</CoverageName>
<CoverageLimit>Upto 50,000</CoverageLimit>
<CoverageAmount>100</CoverageAmount>
<Indicator>TL</Indicator>
</Coverage>
<Coverage>
<CoverageName>EFG</CoverageName>
<CoverageLimit>Upto 50,000</CoverageLimit>
<CoverageAmount>50</CoverageAmount>
<Indicator></Indicator>
</Coverage>
<Coverage>
<CoverageName>HIJ</CoverageName>
<CoverageLimit>Upto 10,000</CoverageLimit>
<CoverageAmount>20</CoverageAmount>
<Indicator></Indicator>
</Coverage>
<Coverage>
<CoverageName>KLM</CoverageName>
<CoverageLimit>Upto 100,000</CoverageLimit>
<CoverageAmount>10</CoverageAmount>
<Indicator>TL</Indicator>
</Coverage></Vehicle>
<Vehicle id="v3">
<Coverage>
<CoverageName>ABC</CoverageName>
<CoverageLimit>Upto 50,000</CoverageLimit>
<CoverageAmount>100</CoverageAmount>
<Indicator>TL</Indicator>
</Coverage>
<Coverage>
<CoverageName>EFG</CoverageName>
<CoverageLimit>Upto 50,000</CoverageLimit>
<CoverageAmount>50</CoverageAmount>
<Indicator></Indicator>
</Coverage>
<Coverage>
<CoverageName>HIJ</CoverageName>
<CoverageLimit>Upto 10,000</CoverageLimit>
<CoverageAmount>20</CoverageAmount>
<Indicator></Indicator>
</Coverage>
<Coverage>
<CoverageName>KLM</CoverageName>
<CoverageLimit>Upto 100,000</CoverageLimit>
<CoverageAmount>10</CoverageAmount>
<Indicator>TL</Indicator>
</Coverage>
</Vehicle>
</Policy>

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by xml_looser
0

it is not so difficult

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="text"/>
	<xsl:template match="/">
		<xsl:apply-templates select="Policy/Vehicle"/>
	</xsl:template>
	<xsl:template match="Vehicle">
		<xsl:text>Vehicle</xsl:text>
		<xsl:value-of select="substring-after(@id,'v')"/>
		<xsl:text>  </xsl:text>
		<xsl:value-of select="Coverage[1]/CoverageName"/>
		<xsl:text> </xsl:text>
		<xsl:value-of select="Coverage[1]/CoverageLimit"/>
		<xsl:text>/</xsl:text>
		<xsl:value-of select="Coverage[2]/CoverageLimit"/>
		<xsl:text>&#xA;</xsl:text>
		<xsl:text>&#xA;</xsl:text>
		<xsl:text>&#xA;</xsl:text>
	</xsl:template>
</xsl:stylesheet>

others way

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="text"/>
	<xsl:template match="/">
		<xsl:apply-templates select="Policy/Vehicle"/>
	</xsl:template>
	<xsl:template match="Vehicle">
		<xsl:text>Vehicle</xsl:text>
		<xsl:value-of select="substring-after(@id,'v')"/>
		<xsl:text>  </xsl:text>
		<xsl:value-of select="Coverage['ABC'=./CoverageName]/CoverageName"/>
		<xsl:text> </xsl:text>
		<xsl:value-of select="Coverage['ABC'=./CoverageName]/CoverageLimit"/>
		<xsl:text>/</xsl:text>
		<xsl:value-of select="Coverage['EFG'=./CoverageName]/CoverageLimit"/>
		<xsl:text>&#xA;</xsl:text>
		<xsl:text>&#xA;</xsl:text>
		<xsl:text>&#xA;</xsl:text>
	</xsl:template>
</xsl:stylesheet>

Helmut Hageann

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.