Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4605226
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T00:24:12+00:00 2026-05-22T00:24:12+00:00

UPDATE Rephrasing the question to clarify confusion. I am using XSLT and XSL:FO translated

  • 0

UPDATE Rephrasing the question to clarify confusion.

I am using XSLT and XSL:FO translated by Apache FOP. I want to print address labels.

INPUT

<?xml version="1.0" encoding="utf-8" ?>
<workOrders>
  <workOrder>
    <number>111</number>
    <PartNumber>110022</PartNumber>
    <col3>222</col3>
    <Qty>333</Qty>
  </workOrder>
  <workOrder>
    <number>111</number>
    <PartNumber>110022</PartNumber>
    <col3>222</col3>
    <Qty>333</Qty>
  </workOrder>

  <!--Manually copy/paste the workOrder until you have 47 of them..-->
</workOrders>

OUTPUT
Page 1 (full page 6 rows x 3 cols)
Page1

Page 2 is same as page 1.

Page 3 (partial page…in this case 4 rows x 3 columns and last item blank)

Page3



UPDATE2
I plugged in Alejandro’s solution. I’m getting an error reported by Apache FOP saying

xsl:template is not allowed in this position in the stylesheet

Here’s the code translated from the HTML stuff to the XSL:FO. The point of error is marked by comment. What did I screw up?

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">

    <fo:layout-master-set>

      <!-- layout for the first page -->
      <fo:simple-page-master master-name="first"
            page-height="11in"
            page-width="8.5in"
            margin-top="1cm"
            margin-bottom="1cm"
            margin-left="1cm"
            margin-right="1cm">
        <fo:region-body margin-top="0cm"/>
        <fo:region-before extent="1cm"/>
        <fo:region-after extent="0cm"/>
      </fo:simple-page-master>

      <!-- layout for the other pages -->
      <fo:simple-page-master master-name="rest"
            page-height="11in"
            page-width="8.5in"
            margin-top="1cm"
            margin-bottom="1cm"
            margin-left="1cm"
            margin-right="1cm">
        <fo:region-body margin-top="0cm"/>
        <fo:region-before extent="1cm"/>
        <fo:region-after extent="0cm"/>
      </fo:simple-page-master>

      <fo:page-sequence-master master-name="basicPSM" >
        <fo:repeatable-page-master-alternatives>
          <fo:conditional-page-master-reference master-reference="first" page-position="first" />
          <fo:conditional-page-master-reference master-reference="rest" page-position="rest" />
          <!-- recommended fallback procedure -->
          <fo:conditional-page-master-reference master-reference="rest" />
        </fo:repeatable-page-master-alternatives>
      </fo:page-sequence-master>

    </fo:layout-master-set>
    <!-- end: defines page layout -->

    <!-- actual layout -->
    <fo:page-sequence master-reference="basicPSM">

      <fo:flow flow-name="xsl-region-body">


  <xsl:template match="/" name="tables"><!--ERROR REFERS TO HERE-->
    <xsl:param name="pRows" select="3"/>
    <xsl:param name="pColumns" select="3"/>
    <xsl:param name="pSequence" select="*/*"/>
    <xsl:variable name="vSize" select="$pRows * $pColumns"/>
    <xsl:for-each select="$pSequence[position() mod $vSize = 1]">
      <xsl:variable name="vPosition" select="position()"/>
      <fo:table table-layout="fixed" width="63mm" border-collapse="separate" wrap-option="wrap">
        <fo:table-body wrap-option="wrap">
          <xsl:call-template name="rows">
            <xsl:with-param name="pSequence"
                 select="$pSequence[
                                    position() > ($vPosition - 1) * $vSize
                                     and
                                    $vPosition * $vSize + 1 > position()
                                 ]"/>
          </xsl:call-template>
        </fo:table-body>
      </fo:table>
    </xsl:for-each>
  </xsl:template>


  <xsl:template name="rows">
    <xsl:param name="pSequence" select="/.."/>
    <xsl:param name="pRow" select="$pRows"/>
    <xsl:if test="$pRow">
      <xsl:call-template name="rows">
        <xsl:with-param name="pSequence" select="$pSequence"/>
        <xsl:with-param name="pRow" select="$pRow - 1"/>
      </xsl:call-template>
      <fo:table-row wrap-option="wrap">
        <xsl:call-template name="columns">
          <xsl:with-param name="pSequence"
               select="$pSequence[
                                    position() > ($pRow - 1) * $pColumns
                                     and
                                    $pRow * $pColumns + 1 > position()
                                 ]"/>
        </xsl:call-template>
      </fo:table-row>
    </xsl:if>
  </xsl:template>

  <xsl:template name="columns">
    <xsl:param name="pSequence" select="/.."/>
    <xsl:param name="pColumn" select="$pColumns"/>
    <xsl:if test="$pColumn">
      <xsl:call-template name="columns">
        <xsl:with-param name="pSequence" select="$pSequence"/>
        <xsl:with-param name="pColumn" select="$pColumn - 1"/>
      </xsl:call-template>
      <fo:table-cell width="90mm">
        <fo:block wrap-option="wrap">
          <xsl:apply-templates select="$pSequence[$pColumn]"/>
        </fo:block>
      </fo:table-cell>
    </xsl:if>
  </xsl:template>

  <xsl:output method="xml"/>
  <xsl:template match="/">
    <xsl:call-template name="tables">
      <xsl:with-param name="pSequence" select="workOrders/workOrder[position()!=1]"/>
    </xsl:call-template>
  </xsl:template>
  <xsl:template match="workOrder">
    <xsl:value-of select="PartNumber"/>
  </xsl:template>

  </fo:flow>
  </fo:page-sequence>
  </fo:root>
</xsl:stylesheet>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T00:24:13+00:00Added an answer on May 22, 2026 at 12:24 am

    This XSLT 1.0 stylesheet:

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:param name="pRows" select="6"/>
        <xsl:param name="pColumns" select="3"/>
        <xsl:variable name="pCells" select="$pRows * $pColumns"/>
        <xsl:template match="workOrders">
            <xsl:apply-templates
                 select="workOrder[position() mod $pCells = 1]"
                 mode="table"/>
        </xsl:template>
        <xsl:template match="workOrder" mode="table">
            <table>
                <xsl:apply-templates
                     select="(.|following-sibling::workOrder
                                   [$pCells > position()])
                                [position() mod $pColumns = 1]"
                     mode="row"/>
            </table>
        </xsl:template>
        <xsl:template match="workOrder" mode="row">
            <tr>
                <xsl:apply-templates
                     select="(.|following-sibling::workOrder
                                   [$pColumns > position()])"
                     mode="cell"/>
            </tr>
        </xsl:template>
        <xsl:template match="workOrder" mode="cell">
            <td>
                <xsl:value-of select="PartNumber"/>
            </td>
        </xsl:template>
    </xsl:stylesheet>
    

    Output (with 47 workOrders):

    <table>
        <tr>
            <td>110022</td>
            <td>110022</td>
            <td>110022</td>
        </tr>
        <tr>
            <td>110022</td>
            <td>110022</td>
            <td>110022</td>
        </tr>
        <tr>
            <td>110022</td>
            <td>110022</td>
            <td>110022</td>
        </tr>
        <tr>
            <td>110022</td>
            <td>110022</td>
            <td>110022</td>
        </tr>
        <tr>
            <td>110022</td>
            <td>110022</td>
            <td>110022</td>
        </tr>
        <tr>
            <td>110022</td>
            <td>110022</td>
            <td>110022</td>
        </tr>
    </table>
    <table>
        <tr>
            <td>110022</td>
            <td>110022</td>
            <td>110022</td>
        </tr>
        <tr>
            <td>110022</td>
            <td>110022</td>
            <td>110022</td>
        </tr>
        <tr>
            <td>110022</td>
            <td>110022</td>
            <td>110022</td>
        </tr>
        <tr>
            <td>110022</td>
            <td>110022</td>
            <td>110022</td>
        </tr>
        <tr>
            <td>110022</td>
            <td>110022</td>
            <td>110022</td>
        </tr>
        <tr>
            <td>110022</td>
            <td>110022</td>
            <td>110022</td>
        </tr>
    </table>
    <table>
        <tr>
            <td>110022</td>
            <td>110022</td>
            <td>110022</td>
        </tr>
        <tr>
            <td>110022</td>
            <td>110022</td>
            <td>110022</td>
        </tr>
        <tr>
            <td>110022</td>
            <td>110022</td>
            <td>110022</td>
        </tr>
        <tr>
            <td>110022</td>
            <td>110022</td>
        </tr>
    </table>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Update : I found almost exact similar question , yet it has slightly different
* UPDATE: *I've already answered my question. But you can still give me advise
[update: I am using MySQL 4.1.25 ] I think this must be a simple
Update: Problem solved, and staying solved. If you want to see the site in
Update 2018 : This question was asked long before PostCSS existed, and I would
Update : answer on how to draw one using Superformula is at the end
UPDATE: I found a Scipy Recipe based in this question! So, for anyone interested,
Update: With iPhone OS 3.0+, the whole UIImagePickerController API has changed. This question and
UPDATE: Based on Slace's response I am now using the latest Official release witch
Update: clarified question (I hope) Hi. I'm developing a plugin in Wordpress and I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.