I have an xml document in which data about machines

<машина ......> <машина ......> <машина ......> <машина ......> 

I need to create an html table in which the data about these machines including their number will lie. How do I create a variable and assign it the number of machines?

I tried this:

 <xsl:for-each select="/машина"> <xsl:variable name="a" select="$a+1"/> </xsl:for-each> 

and different variations of similar constructions but nothing ever came out

  • And why do you need a variable? - Anton Shchyrov
  • Print at the beginning of the table the number of cars - Igor Butkov
  • If you need to number the elements, use xsl:number . In general, give an example of what should happen in the end. - Alexander Petrov
  • Variables in xslt are actually immutable. If you want to organize a loop with changes, it is usually recursive to call a template with a parameter. - Alexander Petrov

1 answer 1

To count the number of elements, you need to use the count() function

 <xsl:value-of select="count(/машина)"/>