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

XSL:FO Numbered lists

Expand Messages
  • Sandra Mcdonnell
    Hey Experts, I m a newby attempting to make the following render a numbered list. The problem is that every item is number 1. I saw this talked about recently
    Message 1 of 7 , Sep 20, 2002
      Hey Experts,

      I'm a newby attempting to make the following render a numbered list. The
      problem is that every item is number 1. I saw this talked about recently
      on either this or the XSL list and attempted to apply the answer, but it
      still ain't working.

      My XML is as follows:

      <?xml version="1.0" encoding="UTF-8"?>
      <!-- edited with XML Spy v4.4 U (http://www.xmlspy.com) by sandy
      (Sourcefire) -->
      <?xml-stylesheet type="text/xsl"
      href="E:\SingleSourcing\SSTemplates\SFDocsXMLtoPDF.xsl"?>
      <Document Author="SandyM" ProductLine="None" SingleProduct="false"
      Type="Conceptual" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:noNamespaceSchemaLocation="E:\SingleSourcing\SSTemplates\DocSchema.xsd">
      <NumList>
      <NumListItem>
      <Step>Do numbered lists work? </Step>
      <StepContinue>Let's try to see if we can add a continued
      explanation to our numbered step.</StepContinue>
      </NumListItem>
      <NumListItem>
      <Step>Second Numbered Item</Step>
      <StepContinue>And its Continuing explanation...</StepContinue>
      </NumListItem>
      </NumList>
      </Document>


      My XSLT is as follows:

      <?xml version="1.0" encoding="UTF-8"?>
      <xsl:stylesheet version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:fo="http://www.w3.org/1999/XSL/Format">
      <xsl:output method="xml"/>

      <xsl:template match="/">

      <xsl:template match="NumList">
      <fo:list-block >
      <xsl:apply-templates/>
      <xsl:for-each select="NumListItem">

      <fo:list-item>
      <fo:list-item-label>
      <fo:block margin-left=".25in" font-size="10">
      <xsl:for-each select="Step [position()]">
      <xsl:number format="1."/>
      </xsl:for-each>
      </fo:block>
      </fo:list-item-label>

      <fo:list-item-body>
      <fo:block margin-left=".5in"
      font-size="10pt" space-after="6pt" >
      <xsl:for-each select="Step">
      <xsl:value-of select="text()"/>
      </xsl:for-each>
      </fo:block>
      </fo:list-item-body>
      </fo:list-item>

      <fo:list-item>
      <fo:list-item-label>
      <fo:block></fo:block>
      </fo:list-item-label>
      <fo:list-item-body>
      <fo:block margin-left=".5in"
      font-size="10pt" space-after="6pt">
      <xsl:for-each select="StepContinue">
      <xsl:value-of select="text()"/>
      </xsl:for-each>
      </fo:block>
      </fo:list-item-body>
      </fo:list-item>
      </xsl:for-each>
      </fo:list-block>
      </xsl:template>


      I appreciate any and all help!!!

      Thanks!
      Sandy
    • G. Ken Holman
      ... Note that Step[position()] is equivalent to Step. You don t give a lot of detail for what you need but if you just want to be counting NuMListItem
      Message 2 of 7 , Sep 21, 2002
        At 2002-09-20 16:44 -0400, Sandra Mcdonnell wrote:
        >The
        >problem is that every item is number 1.
        >...
        > <NumList>
        > <NumListItem>
        > <Step>Do numbered lists work? </Step>
        > <StepContinue>Let's try to see if we can add a continued
        >explanation to our numbered step.</StepContinue>
        > </NumListItem>
        > <NumListItem>
        > <Step>Second Numbered Item</Step>
        > <StepContinue>And its Continuing explanation...</StepContinue>
        > </NumListItem>
        > </NumList>
        >...
        > <xsl:for-each select="NumListItem">
        >
        > <fo:list-item>
        > <fo:list-item-label>
        > <fo:block margin-left=".25in" font-size="10">
        > <xsl:for-each select="Step [position()]">
        > <xsl:number format="1."/>
        > </xsl:for-each>
        > </fo:block>
        > </fo:list-item-label>

        Note that Step[position()] is equivalent to Step.

        You don't give a lot of detail for what you need but if you just want to be
        counting NuMListItem constructs, then use:

        <xsl:number format="1." count="NumListItem"/>

        <xsl:number> will look up the ancestry (starting at the current node)
        looking for what is being counted, and then only does the counting once
        something being counted is found.

        I'm afraid I cannot figure out from the remainder of your code what you are
        trying to do with your Step and StepContinue constructs, but hopefully the
        above will get you your incrementing list item numbers.

        ................ Ken


        --
        Upcoming hands-on in-depth Europe: Sep 18-Sep 20,2002
        XSLT/XPath and XSL-FO North America: Sep 30-Oct 4,2002

        G. Ken Holman mailto:gkholman@...
        Crane Softwrights Ltd. http://www.CraneSoftwrights.com/f/
        Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995)
        ISBN 0-13-065196-6 Definitive XSLT and XPath
        ISBN 0-13-140374-5 Definitive XSL-FO
        ISBN 1-894049-08-X Practical Transformation Using XSLT and XPath
        ISBN 1-894049-10-1 Practical Formatting Using XSL-FO
        Next public training: 2002-09-18,19,30,10-03,12-08,2003-03-04,07
      • Sandra Mcdonnell
        Ken, Thanks for the help, though I gotta say, I can t make your solution work at all. I didn t even get my number 1s on everything. ;-) What I am trying to
        Message 3 of 7 , Sep 23, 2002
          Ken,

          Thanks for the help, though I gotta say, I can't make your solution work
          at all. I didn't even get my number 1s on everything. ;-)

          What I am trying to get is output that appears as follows:

          1. STEP1
          StepContinue1
          2. STEP2
          StepContinue2

          etc etc. So I want the position of the Step element relative to the
          NumListItems in which is resides.

          My XML appears as follows:

          <NumList>
          <NumListItem>
          <Step>step1 </Step>
          <StepContinue> Step continue text </StepContinue>
          <Step> Step 2 </Step>
          <StepContinue> text </StepContinue>
          </NumListItem>
          <NumList>

          I can make my XSL generate my X-FO, and then render to PDF, but I can't
          make the count for the steps work out.

          Hope this clarifies my problem and that you have an excellent answer! I
          appreciate all your time!!!

          Sandy

          G. Ken Holman wrote:

          >At 2002-09-20 16:44 -0400, Sandra Mcdonnell wrote:
          >
          >>The
          >>problem is that every item is number 1.
          >>...
          >> <NumList>
          >> <NumListItem>
          >> <Step>Do numbered lists work? </Step>
          >> <StepContinue>Let's try to see if we can add a continued
          >>explanation to our numbered step.</StepContinue>
          >> </NumListItem>
          >> <NumListItem>
          >> <Step>Second Numbered Item</Step>
          >> <StepContinue>And its Continuing explanation...</StepContinue>
          >> </NumListItem>
          >> </NumList>
          >>...
          >> <xsl:for-each select="NumListItem">
          >>
          >> <fo:list-item>
          >> <fo:list-item-label>
          >> <fo:block margin-left=".25in" font-size="10">
          >> <xsl:for-each select="Step [position()]">
          >> <xsl:number format="1."/>
          >> </xsl:for-each>
          >> </fo:block>
          >> </fo:list-item-label>
          >>
          >
          >Note that Step[position()] is equivalent to Step.
          >
          >You don't give a lot of detail for what you need but if you just want to be
          >counting NuMListItem constructs, then use:
          >
          > <xsl:number format="1." count="NumListItem"/>
          >
          ><xsl:number> will look up the ancestry (starting at the current node)
          >looking for what is being counted, and then only does the counting once
          >something being counted is found.
          >
          >I'm afraid I cannot figure out from the remainder of your code what you are
          >trying to do with your Step and StepContinue constructs, but hopefully the
          >above will get you your incrementing list item numbers.
          >
          >................ Ken
          >
          >
          >--
          >Upcoming hands-on in-depth Europe: Sep 18-Sep 20,2002
          >XSLT/XPath and XSL-FO North America: Sep 30-Oct 4,2002
          >
          >G. Ken Holman mailto:gkholman@...
          >Crane Softwrights Ltd. http://www.CraneSoftwrights.com/f/
          >Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995)
          >ISBN 0-13-065196-6 Definitive XSLT and XPath
          >ISBN 0-13-140374-5 Definitive XSL-FO
          >ISBN 1-894049-08-X Practical Transformation Using XSLT and XPath
          >ISBN 1-894049-10-1 Practical Formatting Using XSL-FO
          >Next public training: 2002-09-18,19,30,10-03,12-08,2003-03-04,07
          >
          >
          >
          >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/
          >
          >



          [Non-text portions of this message have been removed]
        • Percival, Kate
          Hi Sandra, Try That s what we use! Hope it helps, Kate ... From: Sandra Mcdonnell
          Message 4 of 7 , Sep 23, 2002
            Hi Sandra,
            Try <xsl:value-of select="count(preceding-sibling::step) + 1"/>
            That's what we use!
            Hope it helps,
            Kate

            -----Original Message-----
            From: Sandra Mcdonnell [mailto:smcdonnell@...]
            Sent: 23 September 2002 14:53
            To: XSL-FO@yahoogroups.com
            Subject: Re: [XSL-FO] XSL:FO Numbered lists


            Ken,

            Thanks for the help, though I gotta say, I can't make your solution work
            at all. I didn't even get my number 1s on everything. ;-)

            What I am trying to get is output that appears as follows:

            1. STEP1
            StepContinue1
            2. STEP2
            StepContinue2

            etc etc. So I want the position of the Step element relative to the
            NumListItems in which is resides.

            My XML appears as follows:

            <NumList>
            <NumListItem>
            <Step>step1 </Step>
            <StepContinue> Step continue text </StepContinue>
            <Step> Step 2 </Step>
            <StepContinue> text </StepContinue>
            </NumListItem>
            <NumList>

            I can make my XSL generate my X-FO, and then render to PDF, but I can't
            make the count for the steps work out.

            Hope this clarifies my problem and that you have an excellent answer! I
            appreciate all your time!!!

            Sandy

            G. Ken Holman wrote:

            >At 2002-09-20 16:44 -0400, Sandra Mcdonnell wrote:
            >
            >>The
            >>problem is that every item is number 1.
            >>...
            >> <NumList>
            >> <NumListItem>
            >> <Step>Do numbered lists work? </Step>
            >> <StepContinue>Let's try to see if we can add a continued
            >>explanation to our numbered step.</StepContinue>
            >> </NumListItem>
            >> <NumListItem>
            >> <Step>Second Numbered Item</Step>
            >> <StepContinue>And its Continuing explanation...</StepContinue>
            >> </NumListItem>
            >> </NumList>
            >>...
            >> <xsl:for-each select="NumListItem">
            >>
            >> <fo:list-item>
            >> <fo:list-item-label>
            >> <fo:block margin-left=".25in" font-size="10">
            >> <xsl:for-each select="Step [position()]">
            >> <xsl:number format="1."/>
            >> </xsl:for-each>
            >> </fo:block>
            >> </fo:list-item-label>
            >>
            >
            >Note that Step[position()] is equivalent to Step.
            >
            >You don't give a lot of detail for what you need but if you just want to be

            >counting NuMListItem constructs, then use:
            >
            > <xsl:number format="1." count="NumListItem"/>
            >
            ><xsl:number> will look up the ancestry (starting at the current node)
            >looking for what is being counted, and then only does the counting once
            >something being counted is found.
            >
            >I'm afraid I cannot figure out from the remainder of your code what you are

            >trying to do with your Step and StepContinue constructs, but hopefully the
            >above will get you your incrementing list item numbers.
            >
            >................ Ken
            >
            >
            >--
            >Upcoming hands-on in-depth Europe: Sep 18-Sep 20,2002
            >XSLT/XPath and XSL-FO North America: Sep 30-Oct 4,2002
            >
            >G. Ken Holman mailto:gkholman@...
            >Crane Softwrights Ltd. http://www.CraneSoftwrights.com/f/
            <http://www.CraneSoftwrights.com/f/>
            >Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995)
            >ISBN 0-13-065196-6 Definitive XSLT and XPath
            >ISBN 0-13-140374-5 Definitive XSL-FO
            >ISBN 1-894049-08-X Practical Transformation Using XSLT and XPath
            >ISBN 1-894049-10-1 Practical Formatting Using XSL-FO
            >Next public training: 2002-09-18,19,30,10-03,12-08,2003-03-04,07
            >
            >
            >
            >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/
            <http://docs.yahoo.com/info/terms/>
            >
            >



            [Non-text portions of this message have been removed]



            Yahoo! Groups Sponsor

            ADVERTISEMENT

            <http://rd.yahoo.com/M=233214.2377745.3805144.1261774/D=egroupweb/S=17050160
            61:HM/A=1227861/R=0/*http://ads.track-star.com/linker.ts?ts=1;2;312;3_2_11>


            <http://us.adserver.yahoo.com/l?M=233214.2377745.3805144.1261774/D=egroupmai
            l/S=:HM/A=1227861/rand=475184851>

            To unsubscribe from this group, send an email to:
            XSL-FO-unsubscribe@egroups.com



            Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service
            <http://docs.yahoo.com/info/terms/> .




            [Non-text portions of this message have been removed]
          • G. Ken Holman
            ... asking for. ... I m quite confused that you have wrapped all of your steps into a single NumListItem. Is there is only ever one item in the list? if not,
            Message 5 of 7 , Sep 23, 2002
              At 2002-09-23 09:53 -0400, Sandra Mcdonnell wrote:
              >Thanks for the help, though I gotta say, I can't make your solution work
              >at all. I didn't even get my number 1s on everything. ;-)

              :{)} Well, at least I did qualify my answer that I was unsure what you were
              asking for.

              >What I am trying to get is output that appears as follows:
              >
              >1. STEP1
              > StepContinue1
              >2. STEP2
              > StepContinue2
              >
              >etc etc. So I want the position of the Step element relative to the
              >NumListItems in which is resides.
              >
              >My XML appears as follows:
              >
              ><NumList>
              > <NumListItem>
              > <Step>step1 </Step>
              > <StepContinue> Step continue text </StepContinue>
              > <Step> Step 2 </Step>
              > <StepContinue> text </StepContinue>
              > </NumListItem>
              ><NumList>

              I'm quite confused that you have wrapped all of your steps into a single
              NumListItem. Is there is only ever one item in the list? if not, what
              does it mean to have more than one since each one appears to have multiple
              steps?

              >I can make my XSL generate my X-FO, and then render to PDF, but I can't
              >make the count for the steps work out.

              This tells me you are successfully introducing the FO structure needed for
              list items from your XML source with a "flat" set of list items. Most
              people do not recognize the nuances involved in converting a flat
              collection into a nested structure.

              Kate's suggestion of using 1 plus the count of previous steps looks sound!

              ................... Ken


              --
              Upcoming hands-on in-depth Europe: Sep 18-Sep 20,2002
              XSLT/XPath and XSL-FO North America: Sep 30-Oct 4,2002

              G. Ken Holman mailto:gkholman@...
              Crane Softwrights Ltd. http://www.CraneSoftwrights.com/f/
              Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995)
              ISBN 0-13-065196-6 Definitive XSLT and XPath
              ISBN 0-13-140374-5 Definitive XSL-FO
              ISBN 1-894049-08-X Practical Transformation Using XSLT and XPath
              ISBN 1-894049-10-1 Practical Formatting Using XSL-FO
              Next public training: 2002-09-18,19,30,10-03,12-08,2003-03-04,07
            • Sandra Mcdonnell
              Thanks Ken (And Kate!), ... Initially I did not include the NumListItems. I just had the following: Step1 Text
              Message 6 of 7 , Sep 23, 2002
                Thanks Ken (And Kate!),

                >I'm quite confused that you have wrapped all of your steps into a single
                >NumListItem. Is there is only ever one item in the list? if not, what
                >does it mean to have more than one since each one appears to have multiple
                >steps?
                >
                Initially I did not include the NumListItems. I just had the following:

                <NumList>
                <Step> Step1</Step>
                <StepContinue> Text </StepContinue>
                <Step> Step2</Step>
                <StepContinue> Text </StepContinue>
                </NumList>

                But something in the FO List structure made me think I needed the extra
                element... Sigh. I really am new at ALL this. And I read everything I
                can, I just can't always make it work...

                >This tells me you are successfully introducing the FO structure needed for
                >list items from your XML source with a "flat" set of list items. Most
                >people do not recognize the nuances involved in converting a flat
                >collection into a nested structure.
                >
                >Kate's suggestion of using 1 plus the count of previous steps looks sound!
                >
                Alas, when I tried Kate's suggestion, I get NO numbers at all. I think
                maybe I'm placing both it and my attempt at position() in the wrong
                spot, but no amount of maneuvering has been successful.

                Thanks again!

                Sandy
              • G. Ken Holman
                ... Often it is a good rule of thumb to have as much structure as possible without redundancy. It is usually helpful to have containers for anything that is
                Message 7 of 7 , Sep 23, 2002
                  At 2002-09-23 17:13 -0400, Sandra Mcdonnell wrote:
                  >Thanks Ken (And Kate!),
                  >
                  > >I'm quite confused that you have wrapped all of your steps into a single
                  > >NumListItem. Is there is only ever one item in the list? if not, what
                  > >does it mean to have more than one since each one appears to have multiple
                  > >steps?
                  > >
                  >Initially I did not include the NumListItems. I just had the following:
                  >
                  ><NumList>
                  > <Step> Step1</Step>
                  > <StepContinue> Text </StepContinue>
                  > <Step> Step2</Step>
                  > <StepContinue> Text </StepContinue>
                  ></NumList>
                  >
                  >But something in the FO List structure made me think I needed the extra
                  >element... Sigh. I really am new at ALL this. And I read everything I
                  >can, I just can't always make it work...

                  Often it is a good rule of thumb to have as much structure as possible
                  without redundancy. It is usually helpful to have containers for anything
                  that is repeated. Your task will be much easier if you had something along
                  the lines of:

                  <NumList>
                  <NumListItem>
                  <Step> Step1</Step>
                  <StepContinue> Text </StepContinue>
                  </NumListItem>
                  <NumListItem>
                  <Step> Step2</Step>
                  <StepContinue> Text </StepContinue>
                  </NumListItem>
                  </NumList>

                  Not only have you containerized your steps, your required FO tree will be
                  structured identically, and things should fall into place for you.

                  NumList -> list-block
                  NumListItem -> list-item
                  <xsl:number count="NumListItem"/> -> list-item-label
                  Step and StepContinue -> block

                  Again, I'm not sure why you have two "step" thingies. I away from my email
                  in about 5 minutes for the next day or so, so someone else will hopefully
                  follow up with your responses.

                  Good luck (and hang in there)!

                  ............... Ken


                  --
                  Upcoming hands-on in-depth Europe: Sep 18-Sep 20,2002
                  XSLT/XPath and XSL-FO North America: Sep 30-Oct 4,2002

                  G. Ken Holman mailto:gkholman@...
                  Crane Softwrights Ltd. http://www.CraneSoftwrights.com/f/
                  Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995)
                  ISBN 0-13-065196-6 Definitive XSLT and XPath
                  ISBN 0-13-140374-5 Definitive XSL-FO
                  ISBN 1-894049-08-X Practical Transformation Using XSLT and XPath
                  ISBN 1-894049-10-1 Practical Formatting Using XSL-FO
                  Next public training: 2002-09-18,19,30,10-03,12-08,2003-03-04,07
                Your message has been successfully submitted and would be delivered to recipients shortly.