Hi,
We are calling a webservice from asp.net and we are getting an XML document returned. We want to process this document into html using xslt. The document is to do with a shopping cart, and we have got a parent node called CartResults and then child nodes called lineItems and SubLineItems. Structuredd like this:
<CartResults>
<lineItems>
<id>1</id>
</lineItems>
<lineItems>
<id>2</id>
</lineItems>
<subLineItems>
<id>1</id>
</subLineItems>
<subLineItems>
<id>1</id>
</subLineItems>
<subLineItems>
<id>1</id>
</subLineItems>
<subLineItems>
<id>2</id>
</subLineItems>
<subLineItems>
<id>2</id>
</subLineItems>
</CartResults>
What I have at the moment is a loop to loop over all of the lineitems within the document, but when looping over these lineitems I need to be able to find the related sublineitems from within the document. The lineitems and the sublineitems are related via the id element. so when looping over the lineitem ID=1 I need to find the related sublineitems with an id of 1 as well and output them.
this is the what i have at the moment, but i can't help thinking that there is an easier way of doing this:
hope this makles sense to someone out there
TIA
Tony
We are calling a webservice from asp.net and we are getting an XML document returned. We want to process this document into html using xslt. The document is to do with a shopping cart, and we have got a parent node called CartResults and then child nodes called lineItems and SubLineItems. Structuredd like this:
<CartResults>
<lineItems>
<id>1</id>
</lineItems>
<lineItems>
<id>2</id>
</lineItems>
<subLineItems>
<id>1</id>
</subLineItems>
<subLineItems>
<id>1</id>
</subLineItems>
<subLineItems>
<id>1</id>
</subLineItems>
<subLineItems>
<id>2</id>
</subLineItems>
<subLineItems>
<id>2</id>
</subLineItems>
</CartResults>
What I have at the moment is a loop to loop over all of the lineitems within the document, but when looping over these lineitems I need to be able to find the related sublineitems from within the document. The lineitems and the sublineitems are related via the id element. so when looping over the lineitem ID=1 I need to find the related sublineitems with an id of 1 as well and output them.
this is the what i have at the moment, but i can't help thinking that there is an easier way of doing this:
Code:
<xsl:for-each select="//LineItem">
<tr>
<td valign="top"><xsl:call-template name="Description"><xsl:with-param name="id" select="id" /></xsl:call-template></td>
</tr>
</xsl:for-each>
</xsl:template>
<xsl:template name="Description">
<xsl:param name="id" />
<xsl:for-each select="//SubLineItem">
<xsl:if test="$id = id">
-- output data --
</xsl:if>
</xsl:for-each>
hope this makles sense to someone out there
TIA
Tony