Main menu:

 

August 2008
M T W T F S S
« Jul   Sep »
 123
45678910
11121314151617
18192021222324
25262728293031

Site search

Archives

Categories

Tags

Links:

Archive for August 4th, 2008

xsl how to count the nodes in a xml file

I have a xml sample file generated from the schema.
<ns0:PurchaseOrder xmlns:ns0=”http://yourprojectname.Schemas.PO”>
<PONumber>PONumber_0</PONumber>
<PODate>1999-05-31</PODate>
<POQty>POQty_0</POQty>
<Customer>
<Name1>Google</Name1>
<Name1>Google web</Name1>
</Customer>
</ns0:PurchaseOrder>
now, in order to find a countthe nodes in a xml file , you need to place the below code in the buffer are of the inline XSLT call template
<xsl:template name=”MyXsltSampleTemplate”>
<xsl:variable name=”countofPO” select=”count(/*[local-name()='PurchaseOrder' and namespace-uri()='http://yourprojectname.PO']/*[local-name()='Customer' and namespace-uri()='']/*[local-name()='Name1' and namespace-uri()=''])”/>
<xsl:element name=”countofPO”>
<xsl:value-of select=”$countofPO”/>
</xsl:element>
</xsl:template>
Thanks