Skip to main content
1-Visitor
October 12, 2011
Question

How to Capture Generated Section Number in Styler?

  • October 12, 2011
  • 14 replies
  • 2243 views

Hi all,


I am a beginner, a bit overwhelmed with creating my first stylesheet. I know I will have to use FOSI eventually but I am trying to get as much done in Styler first. I was wondering if there is an XPath override to capture the previous element's generated text title number in Styler? I was only able to retreive the title without the number.My element title numbers are restarting at 1 and I would like them to +1 from the previous element's number.


Also, can one output the title number after the element content in Styler, or will I have to do a FOSI edit with a text variable?


I'm using 5.3.


Thanks for any help!


Regards, Caroline

    14 replies

    1-Visitor
    October 14, 2011
    If you make that:

    count(../preceding-sibling::*[not(self::index)][title])

    then you don't have to do any other math, and it adapts to more situations for you.
    My $.02,
    Steve Thompson
    +1(316)977-0515
    cleccese1-VisitorAuthor
    1-Visitor
    October 14, 2011

    Hi Steve,


    Thank you so much! But I am getting the same issue -- coverage is labeled 4 and locinfo is labeled 6. <indexscheme> is not showing up in my PDF so I don't know what it is or what I'm supposed to do with it. It has no content. Maybe I can delete it?


    <coverage>
    <title></title>
    <para></para>
    </coverage>
    <indexscheme>
    <title></title>
    </indexscheme>
    <locinfo>
    <title></title>
    <para></para>
    </locinfo>

    1-Visitor
    October 14, 2011
    You didn't specify the name of your index element, so Steve had to
    guess. Given that the actual name is "indexscheme", you'll need to
    adjust Steve's version to:

    count(../preceding-sibling::*[not(self::indexscheme)][title])

    I still think you'll need a "+ 1" on the end, but you should be able
    to see pretty easily if that's the case. This translates, roughly, to
    'go up to the parent (..) element of the title and count all of the
    preceding sibling (please let me know if you're not sure what that
    means) elements (* = element of any name) that are not "indexscheme"
    elements and that have a "title" child element'. XPath lets you get
    arbitrarily specific about what you want to count, so there's pretty
    much no reason why you can't get a single expression that works for
    all cases without having to artificially add a "- 1" or the like on
    certain cases to accommodate one particular document.

    If there are any other twists in this tale or details that you've
    omitted, please fill us in, as the sooner you can give us a complete,
    accurate and concrete description of the problem you're trying to
    solve, the sooner we can give you a complete, working solution.

    -Brandon 🙂


    On Fri, Oct 14, 2011 at 2:27 PM, Caroline Leccese
    <caroline@thecodesource.net> wrote:
    > Hi Steve,
    >
    > Thank you so much! But I am getting the same issue -- coverage is labeled 4
    > and locinfo is labeled 6. <indexscheme> is not showing up in my PDF so I
    > don't know what it is or what I'm supposed to do with it. It has no content.
    > Maybe I can delete it?
    >
    > <coverage>
    > <title></title>
    > <para></para>
    > </coverage>
    > <indexscheme>
    > <title></title>
    > </indexscheme>
    > <locinfo>
    > <title></title>
    > <para></para>
    > </locinfo>
    >
    > -----End Original Message-----
    cleccese1-VisitorAuthor
    1-Visitor
    October 14, 2011

    Hi Brandon,


    Thank you, that resolved it! I have zero experience with XPath and the lightbulb didn't go on regarding index/indexscheme until I had looked at the two XPATH expressions side by side.Your explanation was helpful. The XPATH syntax just wasn't clicking for me.


    I am so grateful for everyone's help!