How to populate a variable dynamically
Hi,
My requirement is ,
i have to print the count of multiple occurances of any tag.
by using count function i found the the occurances. i am failing at pass the value.
input xml :
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<Response xmlns="http://test.com">
<Result>
<Users>
<Summary>
<ID>186886</ID>
<Status>N</Status>
</Summary>
<Summary>
<ID>186888</ID>
<Status>N</Status>
</Summary>
</Users>
</Result>
</Response>
</soap:Body>
</soap:Envelope>
summary tag is occuring twice so RowCount =2
xslt :
XSLT :<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:o="http://test.com.websevices">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no" />
<xsl:template match="/soap:Envelope">
<xsl:apply-templates select="soap:Body"/>
</xsl:template>
<xsl:template match="soap:Body">
<LMPResponse>
<Message>Details
<RowCount><xsl:value-of select="count(o:Response /o:Result /o:Users /o:Summary)"/>
</RowCount>
<Section RowCount="populate the value from RowCount">Details
<xsl:for-each select="o:Response /o:Result /o:Users /o:Summary">
<Row>
<ID>
<xsl:value-of select="o:Response /o:Result /o:Users /o:Summary /o:ID"/>
</ID>
<Status>
<xsl:value-of select="o:Response /o:Result /o:Users /o:Summary/o:Status"/>
</Status>
</Row>
</xsl:for-each>
</Section>
<Section RowCount="0">Footer</Section>
</Message>
</LMPResponse>
</xsl:template>
</xsl:stylesheet>
now i am not able to populate the count found in RowCount using
<RowCount><xsl:value-of select="count(o:Response /o:Result /o:Users /o:Summary)"/>
</RowCount> to <Section RowCount="populate the value from RowCount">
Can any one help in this.
Thanks,
Divya
|