How to increment a XSL integer variable

前端 未结 4 1756
花落未央
花落未央 2020-12-19 19:51

Updated

I have some huge data, which becomes a large table say table parent

each table parent\'s row will

相关标签:
4条回答
  • 2020-12-19 20:25

    The notion of an increment is foreign to XSLT as a functional language. However, you could just count the number of preceding elements:

    <xsl:value-of select="count(preceding-sibling::ORSReposTableTypeInd1)"/>
    

    Depending on your document layout, this might get more complicated, your milage may vary.

    0 讨论(0)
  • 2020-12-19 20:38

    I have same problem and simplest way to solve it is to use Saxon. Here you can find my solution Incrementing and checking the counter variable in XSLT

    0 讨论(0)
  • 2020-12-19 20:41

    Use position(). Since you are incrementing this once per for-each why don't you simply use position()?

    <a name="_ORS$counter" href="#_top">ORSReposColumAllWithTableTypeInd1:<xsl:value-of select="position()"/> </a>
    
    0 讨论(0)
  • 2020-12-19 20:50

    What about using:

    <xsl:number/>
    

    See http://www.w3.org/TR/xslt#number

    There are various ways to include it as attributes into your anchor tag.

    Option 1: Using variables

    <xsl:variable name="number">
      <xsl:number/>
    </xsl:variable>
    <a name="{$number}">blabla</a>
    

    Option 2: xsl:attribute

    <a>
      <xsl:attribute name="name">
        <xsl:number/>
      </xsl:attribute>
    </a>
    
    0 讨论(0)
提交回复
热议问题