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

Positioning Node Members Dynamically in a Table

Expand Messages
  • shawnlstroud@yahoo.com
    Well, the title pretty much says it all, doesn t it? I need to dynamically position members of a node set in one of two columns in a table. I m looking to be
    Message 1 of 5 , Oct 2, 2001
    • 0 Attachment
      Well, the title pretty much says it all, doesn't it?

      I need to dynamically position members of a node set in one of two
      columns in a table. I'm looking to be able to produce a list like:
      1 2
      3 4
      5 6

      or

      1 3
      2 4
      3 6

      I'm not fussy about exactly how.

      Any ideas?
    • Paul Tyson
      Shawn, here s one way to turn a of s into a 2-column table in row-major order:
      Message 2 of 5 , Oct 2, 2001
      • 0 Attachment
        Shawn, here's one way to turn a <list> of <item>s into a 2-column table in
        row-major order:

        <xsl:template match="list">
        <fo:table>
        <fo:table-body>
        <xsl:call-template name="make-rows"/>
        </fo:table-body>
        </fo:table>
        </xsl:template>

        <xsl:template match="item">
        <fo:table-cell><xsl:apply-templates/></fo:cell>
        </xsl:template>

        <xsl:template name="make-rows">
        <xsl:param name="nth-item" select="1"/>
        <xsl:choose>
        <xsl:when test="$nth-item > count(item)"/>
        <xsl:otherwise>
        <fo:table-row>
        <xsl:apply-templates
        select="item[position() >= $nth-item and
        position() < $nth-item + 2]"/>
        </fo:table-row>
        <xsl:call-template name="make-rows">
        <xsl:with-param name="nth-item" select="$nth-item + 2"/>
        </xsl:call-template>
        </xsl:otherwise>
        </xsl:choose>
        </xsl:template>

        You could parameterize the number of columns instead of hard-code it at 2.

        It's a little trickier to get column-major ordering, but not bad once you
        understand it. A similar approach to produce HTML tables is illustrated at
        http://www.biglist.com/lists/xsl-list/archives/200109/msg01364.html. If
        this doesn't help, post again and I'll explain it more fully.

        Have fun,

        Paul Tyson, Principal Consultant Precision Documents
        paul@... http://precisiondocuments.com
        "The art and science of document engineering."


        ----- Original Message -----
        From: <shawnlstroud@...>
        To: <XSL-FO@yahoogroups.com>
        Sent: Tuesday, October 02, 2001 7:54 AM
        Subject: [XSL-FO] Positioning Node Members Dynamically in a Table


        > Well, the title pretty much says it all, doesn't it?
        >
        > I need to dynamically position members of a node set in one of two
        > columns in a table. I'm looking to be able to produce a list like:
        > 1 2
        > 3 4
        > 5 6
        >
        > or
        >
        > 1 3
        > 2 4
        > 3 6
        >
        > I'm not fussy about exactly how.
        >
        > Any ideas?
        >
        >
        >
        > To unsubscribe from this group, send an email to:
        > XSL-FO-unsubscribe@egroups.com
        >
        >
        >
        > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
        >
        >
      • Christopher R. Maden
        ... Perhaps... do you really mean dynamically ? ... You can produce an FO table that orders a list in row-major or column-major fashion, but either
        Message 3 of 5 , Oct 2, 2001
        • 0 Attachment
          At 07:54 2-10-2001, shawnlstroud@... wrote:
          >Well, the title pretty much says it all, doesn't it?

          Perhaps... do you really mean "dynamically"?

          >I need to dynamically position members of a node set in one of two
          >columns in a table. I'm looking to be able to produce a list like:
          >1 2
          >3 4
          >5 6
          >
          >or
          >
          >1 3
          >2 4
          >3 6

          You can produce an FO table that orders a list in row-major or column-major
          fashion, but either transformation is going to be static. If that's all
          you're asking, then Paul's row-major solution will work, and there are
          examples in Jeni Tennison's grouping FAQ about producing HTML tables in
          column-major order (see <URL: http://www.jenitennison.com/xslt/grouping/ >)
          with XSLT.

          If you're looking for something truly dynamic, you could use the multi
          objects, but I don't know of any system that actually supports those yet.

          -Chris
          --
          Christopher R. Maden, Principal Consultant, HMM Consulting Int'l, Inc.
          DTDs/schemas - conversion - ebooks - publishing - Web - B2B - training
          <URL: http://www.hmmci.com/ > <URL: http://crism.maden.org/consulting/ >
          PGP Fingerprint: BBA6 4085 DED0 E176 D6D4 5DFC AC52 F825 AFEC 58DA
        • shawnlstroud@yahoo.com
          Paul, thanks for the help. I m fairly new to the XSL-FO thing, so your code example really hits the spot.
          Message 4 of 5 , Oct 3, 2001
          • 0 Attachment
            Paul, thanks for the help. I'm fairly new to the XSL-FO thing, so
            your code example really hits the spot.
          • shawnlstroud@yahoo.com
            ... Well, by dynamically I mean that I don t know the number of nodes in the result tree, so I need to be able to sort and arrange the nodes on the fly.
            Message 5 of 5 , Oct 3, 2001
            • 0 Attachment
              --- In XSL-FO@y..., "Christopher R. Maden" <crism@m...> wrote:
              > At 07:54 2-10-2001, shawnlstroud@y... wrote:
              > >Well, the title pretty much says it all, doesn't it?
              >
              > Perhaps... do you really mean "dynamically"?
              >
              Well, by "dynamically" I mean that I don't know the number of nodes
              in the result tree, so I need to be able to sort and arrange the
              nodes on the fly.

              Hmmm. I bet there's a better word for that than "dynamic."

              Anyway, thank you for your quick response. I'm checking out and
              testing the code examples and suggestions today.
            Your message has been successfully submitted and would be delivered to recipients shortly.