Skip to main content
Nov 18, 2013 10:29 PM UTC
Question

XPATH question

Hi All,


This is my markup:
<sim>
</sim>


I am only interested in capturing the text "some text here", ie all text that comes before any of the children of <sim>


I think <titlepg> is always the first child so I can have it stop there


Can this be done in XPATH?

    5 replies

    Nov 18, 2013 10:51 PM UTC
    Hi Caroline,

    Maybe something like this would work:

    /sim/text()[not(preceding-sibling::*)]

    Nov 19, 2013 12:00 AM UTC
    Caroline,



    That looks like the supporting information chapter from 40051. If that is
    the case, I'm not sure what you are putting between the <sim> and <titlep>.
    The first child of <sim> is <titlepg>.

    The style sheet might put some generic information (chapter number and
    SUPPORTING INFORMATION) there, but I can't think of anything else that would
    be there, content wise at least.



    Richard, would your XPATH capture system generated text? I don't think so.
    I guess it would depend on when the expression is called. During editing,
    other than comments, there is nothing allowed.





    Lynn
    (the LEH in the DTD)


    clecceseAuthor
    Nov 19, 2013 12:19 AM UTC

    Lynn, you're right, I just wanted to capture the Chapter Title and "SUPPORTING INFORMATION" so I could check the length for PDF bookmarks because there seems to be a character limit on the bookmarks and some of the titles are too long. (Actually I should have been testing a <mim>, the <sim> length is OK.) You're also right it's generated text so XPATh doesn't work. Oh well!

    Nov 19, 2013 2:15 AM UTC
    Caroline,

    You might be able to capture the FO output during the post processing and check string length through that.

    Another possibility is to populate an array with the chapter type and maintenance level information and then based on the parent element (e.g., <mim> or <sim>) and the maintenance level attribute you could build a pseudo title.

    The chapter title page FO file has the information you'd need for this.


    Lynn
    ---- Caroline Leccese <caroline@thecodesource.net> wrote:
    > Lynn, you're right, I just wanted to capture the Chapter Title and "SUPPORTING INFORMATION" so I could check the length for PDF bookmarks because there seems to be a character limit on the bookmarks and some of the titles are too long. (Actually I should have been testing a <mim>, the <sim> length is OK.) You're also right it's generated text so XPATh doesn't work. Oh well!
    >
    >
    > -----End Original Message-----
    Nov 19, 2013 2:50 PM UTC
    Right Lynn, XPath wouldn't grab generated text produced from the
    stylesheet, it only pulls information from the XML.