Loading ...
Sorry, an error occurred while loading the content.
 

Difference in position() statement

Expand Messages
  • Whitney, Dan (FPDG)
    Was wondering why these 2 position statements are different (when using fop.0.20.4 I get very different results and I m not sure why): Statement 1:
    Message 1 of 2 , Oct 29 9:27 AM
      Was wondering why these 2 position statements are different (when using
      fop.0.20.4 I get very different results and I'm not sure why):

      Statement 1:

      <xsl:template match="RECORD [@fragid='13'] [position() = 1]">
      <fo:block font-weight="bold">
      <xsl:text>Splits/Consolidations:</xsl:text>
      </fo:block>
      <xsl:apply-templates/>
      </xsl:template>

      <xsl:template match="RECORD [@fragid='13'] [position() = 2]">
      <fo:block font-weight="bold">
      <xsl:text>Note:</xsl:text>
      </fo:block>
      <xsl:apply-templates/>
      </xsl:template>

      Statement 2:

      <xsl:template match="RECORD [@fragid='13']">
      <xsl:choose>
      <xsl:when test="position() = 1">
      <fo:block font-weight="bold">
      <xsl:text>Splits/Consolidations:</xsl:text>
      </fo:block>
      </xsl:when>
      <xsl:when test="position() = 2">
      <fo:block font-weight="bold">
      <xsl:text>Note:</xsl:text>
      </fo:block>
      </xsl:when>
      <xsl:apply-templates/>
      </xsl:template>

      Here is my xml fragment I am applying it to:


      <RECORD fragment="surveys" desc="BMO">
      <ID idtype="fpid">3776</ID>
      <INDEXEDIDREF producttype="6">B.38</INDEXEDIDREF>
      <INDEXENTRY producttype="6" marker="sort">Bank Of Montreal</INDEXENTRY>
      <INDEXENTRY producttype="6" marker="legal">Bank of Montreal</INDEXENTRY>
      <RECORD fragid="12">
      ....
      </RECORD>
      <RECORD fragment="splits" recid="3776" fragid="13" product="surveys"
      group="surveys" status="1">
      <ID idtype="fpid">3776</ID>
      <RECORDSECTION docfragment="splits" status="L">
      <ID idtype="fpsid">1289</ID>
      <RECORDITEM year="-1" desc="split">2-for-1 split in March
      2001</RECORDITEM>
      <RECORDITEM year="-9" desc="split">2-for-1 split in March
      1993</RECORDITEM>
      </RECORDSECTION>
      </RECORD>
      <RECORD fragment="splits" recid="3776" fragid="13" product="surveys"
      group="surveys" status="1">
      <ID idtype="fpid">3776</ID>
      <RECORDSECTION docfragment="splits" status="L">
      <ID idtype="fpsid">1289</ID>
      <RECORDITEM year="-1" desc="split">2-for-1 split in March
      2001</RECORDITEM>
      <RECORDITEM year="-9" desc="split">2-for-1 split in March
      1993</RECORDITEM>
      </RECORDSECTION>
      </RECORD>
      </RECORD>

      Thanks in advance,

      Dan
    • Oleg Tkachenko
      Hello! You need more deep understanding of xslt processing model, take a look at http://www.w3.org/TR/xslt.html#section-Processing-Model ... This one matches
      Message 2 of 2 , Oct 29 10:06 AM
        Hello!

        You need more deep understanding of xslt processing model, take a look at
        http://www.w3.org/TR/xslt.html#section-Processing-Model

        > <xsl:template match="RECORD [@fragid='13']">

        This one matches all RECORD with @fragid='13', but when the template is
        instantiated, current node list contains all children of the outermost RECORD
        element, as it was selected by <xsl:apply-templates/> within built-in
        template. So the current node has position equals to 6 and then 7 (well, using
        msxml, which strips all whitespace only text nodes).

        PS. For more comprehensive explanation ask on more xslt specialized list, e.g.
        xsl-list at http://www.mulberrytech.com/xsl/xsl-list.
        --
        Oleg Tkachenko
        eXperanto team
        Multiconn Technologies, Israel
      Your message has been successfully submitted and would be delivered to recipients shortly.