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

XPath display multiple elements in one table question

Expand Messages
  • odekij61
    Hello, I have an element lsa-tube, that can be at many different levels in my xml hierarchy. I need to display the lsa-tubes in one table if they immediately
    Message 1 of 3 , Mar 26, 2004
    • 0 Attachment
      Hello,

      I have an element lsa-tube, that can be at many different levels in my
      xml hierarchy. I need to display the lsa-tubes in one table if they
      immediately after each other in document order. I think to do this I
      have to match lsa-tube[1] and start a table, and do a for-each
      following-direct-siblings append table rows. What's the XPath to
      match a bunch of lsa-tubes directly after the current until a
      non-lsa-tube element?

      I am sure I read how to create tables with variable amount of rows
      somewhere, but I cannot find it in my books, or online.

      Any help/links are greatly appreciated.

      Thanks,
      Jeremy Odekirk
    • odekij61
      Hello, I found the answer to my question in grouping chapter in my XSLT and XPath on the Edge book. To match the 1st lsa-tube in an adjacent set I matched
      Message 2 of 3 , Mar 29, 2004
      • 0 Attachment
        Hello,

        I found the answer to my question in grouping chapter in my "XSLT and
        XPath on the Edge" book.
        To match the 1st lsa-tube in an adjacent set I matched this:
        lsa-tube[not(preceding-sibling::*[1][self::lsa-tube])]

        To match the rest and not display them I did this:
        <xsl:template match="lsa-tube[preceding-sibling::*
        [1][self::lsa-tube]]"/>

        Summary.... I find the 1st lsa-tube and create a table, and then
        inside that template I find the rest and add rows. I then created a
        template that does not display anything for the non 1st lsa-tubes.
        This allows me to create one table when multiple lsa-tubes are in a
        row.

        Hope this helps other people.
        Thanks,
        Jeremy Odekirk


        --- In XSL-FO@yahoogroups.com, "odekij61" <odekij61@y...> wrote:
        > Hello,
        >
        > I have an element lsa-tube, that can be at many different levels in
        my
        > xml hierarchy. I need to display the lsa-tubes in one table if they
        > immediately after each other in document order. I think to do this I
        > have to match lsa-tube[1] and start a table, and do a for-each
        > following-direct-siblings append table rows. What's the XPath to
        > match a bunch of lsa-tubes directly after the current until a
        > non-lsa-tube element?
        >
        > I am sure I read how to create tables with variable amount of rows
        > somewhere, but I cannot find it in my books, or online.
        >
        > Any help/links are greatly appreciated.
        >
        > Thanks,
        > Jeremy Odekirk
      • odekij61
        Hello, I found out my grouping lsa-tubes into a table code is not complete. I am confused on how to select all following-siblings after I find the 1st in the
        Message 3 of 3 , Apr 8 1:54 PM
        • 0 Attachment
          Hello,

          I found out my grouping lsa-tubes into a table code is not complete.
          I am confused on how to select all following-siblings after I find the
          1st in the group. The table starts correctly for each group of
          lsa-tubes, but then it only adds the next following lsa-tube. How do
          I select the rest of the following-sibling lsa-tubes in the group? It
          looks like I have to make this recursive somehow.

          Here's my code.

          <xsl:template
          match="lsa-tube[not(preceding-sibling::*[1][self::lsa-tube])]">
          <fo:block-container >
          <fo:table >
          <xsl:call-template name="lsa-tube-header-row"/>
          <xsl:call-template name="lsa-tube-content-row"/>
          <xsl:for-each select="following-sibling::*[1][self::lsa-tube]">
          <xsl:call-template name="lsa-tube-content-row"/>
          </xsl:for-each>
          </fo:table>
          </fo:block-container>
          </xsl:template>

          My for-each only selects the next following lsa-tube in the group.
          How do I change this to select all following in a group? This grouping
          in XPath seems hard.

          Any help is greatly appreciated.

          Thanks,
          Jeremy Odekirk

          --- In XSL-FO@yahoogroups.com, "odekij61" <odekij61@y...> wrote:
          > Hello,
          >
          > I found the answer to my question in grouping chapter in my "XSLT
          and
          > XPath on the Edge" book.
          > To match the 1st lsa-tube in an adjacent set I matched this:
          > lsa-tube[not(preceding-sibling::*[1][self::lsa-tube])]
          >
          > To match the rest and not display them I did this:
          > <xsl:template match="lsa-tube[preceding-sibling::*
          > [1][self::lsa-tube]]"/>
          >
          > Summary.... I find the 1st lsa-tube and create a table, and then
          > inside that template I find the rest and add rows. I then created a
          > template that does not display anything for the non 1st lsa-tubes.
          > This allows me to create one table when multiple lsa-tubes are in a
          > row.
          >
          > Hope this helps other people.
          > Thanks,
          > Jeremy Odekirk
          >
          >
          > --- In XSL-FO@yahoogroups.com, "odekij61" <odekij61@y...> wrote:
          > > Hello,
          > >
          > > I have an element lsa-tube, that can be at many different levels
          in
          > my
          > > xml hierarchy. I need to display the lsa-tubes in one table if
          they
          > > immediately after each other in document order. I think to do
          this I
          > > have to match lsa-tube[1] and start a table, and do a for-each
          > > following-direct-siblings append table rows. What's the XPath to
          > > match a bunch of lsa-tubes directly after the current until a
          > > non-lsa-tube element?
          > >
          > > I am sure I read how to create tables with variable amount of rows
          > > somewhere, but I cannot find it in my books, or online.
          > >
          > > Any help/links are greatly appreciated.
          > >
          > > Thanks,
          > > Jeremy Odekirk
        Your message has been successfully submitted and would be delivered to recipients shortly.