Need to manipulate X and Y positions (and page break) via XSLT

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cheesebread
    New Member
    • Feb 2010
    • 2

    Need to manipulate X and Y positions (and page break) via XSLT

    Hi

    Bit of a tricky question (I think). I am trying to print stickers/labels using a process by which I am converting XML to HTML (using XSLT) then convert to .PDF then print. The stickers themselves are all 1X1 and 64 can fit on the page (8 rows with 8 columns). Each set of stickers will have a header sticker with slightly different info. I have formatted the XML input to have a header node and a collection of child nodes associated which are the stickers themselves.

    Conceptually I would like to build a table in html and for each header or sticker build a 1X1 inside a <td>. The trick will be to track 1 through 8 across (then need a new <tr> and also track the vertical (need a page break). There is no limit to how many stickers there can be. Since XSLT variable declarations are essentialy immutable and don't behave like counters, how do I track the X,Y positions and build this out in an XSLT without having to create 64 tables, etc... I was looking at calling a C# method but this seems to be a last resort.

    Thanks
  • drhowarddrfine
    Recognized Expert Expert
    • Sep 2006
    • 7434

    #2
    There are counters in xslt and you can do math but don't ask me any more about it cause I've never used it.

    Comment

    • cheesebread
      New Member
      • Feb 2010
      • 2

      #3
      I was reading about position() as it relates to relate position in the XML doc. I could in theory even use the mod function to break on 8th row but I don't know how I would track my vertical position on the page.

      Thanks.

      Comment

      • jkmyoung
        Recognized Expert Top Contributor
        • Mar 2006
        • 2057

        #4
        Are you using xsl-fo?

        Can think of several ways, depending on your xml layout, eg roughly:

        [code=xml]
        apply-templates select="sticker[position() mod 8 = 1]" mode="row"


        <template match="sticker" mode="row">
        <tr>
        <xsl:apply-template select=".|follo wing-sibling:sticker[position() &lt; 8]"/>
        </tr>
        <xsl:if test="position( ) mod 64 = 1"> <!-- can't remember if you need 8 or 64 here; try it out. -->
        break
        </xsl:if>
        </template>

        <template match="sticker" >
        <td>
        some output here..
        </td>
        </template>
        [/code]

        Comment

        Working...