Skip to main content
1-Visitor
Nov 5, 2011 7:45 AM UTC
Question

help with XPATH

I am using this expression:


count(../preceding::*[(self::figure)][title]) +1 to count figures


but I would like it to reset when it hits a <wpno> tag which seems doable but I can't get the syntax correct.<wpno> is an inline tag, it doesn't have children.


Thanks in advance!


    9 replies

    1-Visitor
    Nov 5, 2011 12:34 PM UTC
    As a first step, you can simplify the original to:

    count(preceding::figure[title]) + 1

    We want to count the figures since the last <wpno> or, equivalently,
    the preceding figures minus the figures preceding the last <wpno>.

    count(preceding::figure[title]) -
    count(preceding::wpno[1]/preceding::figure[title]) + 1

    -Brandon 🙂


    On Sat, Nov 5, 2011 at 3:45 AM, Caroline Leccese
    <caroline@thecodesource.net> wrote:
    > I am using this expression:
    >
    > count(../preceding::*[(self::figure)][title]) +1 to count figures
    >
    > but I would like it to reset when it hits a <wpno> tag which seems doable
    > but I can't get the syntax correct.<wpno> is an inline tag, it doesn't have
    > children.
    >
    > Thanks in advance!
    >
    >
    >
    > ----------
    Translate
    cleccese1-VisitorAuthor
    1-Visitor
    Nov 5, 2011 11:12 PM UTC

    It works. Awesome. Thanks, Brandon!


    Regards,Caroline

    Translate
    1-Visitor
    Nov 7, 2011 1:38 PM UTC
    When it comes to matters of XSLT and XPath, never. doubt. Brandon. When it comes to his choice of office locations, that's another story...
    Translate
    1-Visitor
    Nov 7, 2011 1:52 PM UTC
    Hey, now! I've upgraded in the office department since the last time
    you visited. I even go there and use it, from time to time...

    -Brandon 🙂


    Translate
    cleccese1-VisitorAuthor
    1-Visitor
    Nov 12, 2011 10:24 AM UTC

    I am using this in a header:


    //wpno/text()


    but I want it to use the current wpno. This is just returning the first wpno of the document for all the pages. Is this doable in a header? When I tried the "Insert element content" menu in the header in Styler, I was never able to return anything, which is why I'm trying to figure out this XPATH. I tried experimenting with "preceding::wpno" but that hung up my CPU.


    Not sure if I'm making sense. Thanks for any help!

    Translate
    1-Visitor
    Nov 12, 2011 1:22 PM UTC
    When you say 'current wpno', do you mean the most recent one seen in traversing the document, the parent of the current element(s), or the wpno itself as the current element?

    Steve Thompson
    +1(316)977-0515
    Translate
    1-Visitor
    Nov 12, 2011 3:22 PM UTC

    Translate
    1-Visitor
    Nov 12, 2011 5:01 PM UTC
    Paul's explanation is, as always, excellent. The only thing I'd add
    is that you can probably get the <wpno> by creating a new Cross
    Reference format ("Format" menu, "Cross References") in Styler, to be
    used in the Division Reference that you insert into your header.

    When editing your new Cross Reference format, use an "XPath String" or
    "Elements Via XPath" to insert the value of the "wpno" element,
    remembering that the XPath will be evaluated in the context of
    whatever element is styled as a Title in your division, so you may
    need to navigate up a level (..) and then down a level or two to get
    to the "wpno".

    -Brandon 🙂


    Translate
    cleccese1-VisitorAuthor
    1-Visitor
    Nov 17, 2011 4:52 AM UTC

    Thank you so much everyone for your advice. (Steve, I meant the most recent wpno seen in traversing the document, it does not have children and there is only one per section (wp). Page numbering, headers, etc must be restarted in each wp.)

    Translate