Skip to main content
1-Visitor
July 12, 2012
Question

xpath equivalent of FOSI #CONTENT?

  • July 12, 2012
  • 24 replies
  • 4871 views

    24 replies

    18-Opal
    July 12, 2012
    Hi Suzanne--



    Try this:



    string(following-sibling::title[1])



    That should give you all the text inside the title, including text
    inside any child elements.



    --Clay



    Clay Helberg

    Senior Consultant

    TerraXML


    1-Visitor
    July 12, 2012
    Hi Clay!

    This yields the text but not <brk>.

    Suzanne


    1-Visitor
    July 12, 2012
    I don't think you can get what you want with this approach, due to what the
    FOSI engine does with the result of the XPath expression (nothing to do
    with XPath, itself). Each of your examples and the stated result is
    consistent with the string value of the first node in the result being
    used. You got closest with "following-sibling::title[1]" (or the version
    without "[1]"), but since the string value is being taken, you'll never get
    the <brk>.

    I think (not tested) you might get what you want with:

    <e-i-c gi="a">
    ...
    <att>
    <charsubset>
    <savetext textid="title.txt" conrule="#XPATHCONTENT(&lt;br"/>following-sibling::title[1])#XPATH">
    ...

    -Brandon 🙂


    On Thu, Jul 12, 2012 at 5:41 PM, Suzanne Napoleon <
    SuzanneNapoleon@fosiexpert.com> wrote:

    > What is the xpath equivalent of FOSI #CONTENT? I need to save an
    > element's #PCDATA and any tags. Not PIs, although FOSI probably would
    > ignore them.
    >
    > The SGML doc has the following. Note that and <brk> are singletons.
    >
    >
    <title>Lorem ipsum<brk>dolor sit amet</title>
    >
    >
    > In the FOSI, preceding sibling
    is trying to save the <title>
    > element's #CONTENT. The FOSI had the following, which worked until <brk>
    > was added to the title:
    >
    > <e-i-c gi="a">
    > ...
    > <att>
    > <fillval attname="following-sibling::title[1]/text()" attloc="#XPATH" fillcat="savetext"&lt;br"/>> fillchar="conrule"/>
    > <charsubset>
    > <savetext textid="title.txt">
    > ...
    >
    > When <brk> is added in the title, #PCDATA is captured up to but not
    > including the <brk> tag.
    >
    > Here is what I've tried, and the results:
    >
    > following-sibling::title[1]/text() captures the content up to but not
    > including the <brk> tag.
    > following-sibling::title[1]/node() ditto.
    > following-sibling::title[1] saves all the #PCDATA but not <brk>.
    > following-sibling::title ditto
    > following-sibling::title[1]/string() saves nothing.
    >
    > Thanks for any ideas!
    >
    > Suzanne Napoleon
    > www.FOSIexpert.com
    > "WYSIWYG is last-century technology!"
    >
    1-Visitor
    July 12, 2012
    Hi Brandon!

    I'll give it a try.

    Thanks!
    Suzanne


    18-Opal
    July 12, 2012
    Hi Suzanne--



    Ok, I had to go back and reread your original post. At first I thought
    you wanted to capture some text content inside the child element, but I
    see you actually want the child element markup. As Brandon pointed out,
    the way FOSI is using XPath in this instance coerces it to a string,
    which is why you are only getting text content and no markup.



    My FOSI-fu is weak, so I don't really know the differences between the
    different ways that FOSIs can invoke XPath. Brandon's suggested approach
    may work. If not, you might have to consider replacing the XPath
    approach with a pure FOSI variable approach, which I suspect you can
    work out with both hands tied behind your back. 🙂



    --Clay





    Clay Helberg

    Senior Consultant

    TerraXML


    1-Visitor
    July 12, 2012
    Nothing gets saved with that.
    Suzanne


    1-Visitor
    July 12, 2012
    Hi Suzzane,



    You could try do this:

    <savetext textid="title.txt"&lt;br"/>conrule="#XPATHNODESET(following-sibling::title[1])#XPATHNODESET">



    Thanks and Regards,

    Suresh.

    On Fri, Jul 13, 2012 at 10:11 AM, Suzanne Napoleon <
    SuzanneNapoleon@fosiexpert.com> wrote:

    > Nothing gets saved with that.
    > Suzanne
    >
    1-Visitor
    July 12, 2012
    Hi Suzzane,

    I was wrong.
    it should have been.

    #XPATHNODESET( following-sibling::title[1])#XPATH">

    Thanks and Regards,
    Suresh.
    1-Visitor
    July 12, 2012
    Hmm... I'm surprised you don't get anything. The next thing I'd try is
    almost the same as Suresh's version, replacing "#XPATHCONTENT" with
    "#XPATHNODESET", but adding a "/node()" to the XPath expression. That
    should get you just the content of the "title" element, without the element
    itself:

    #XPATHNODESET(following-sibling::title[1]/node())#XPATH

    -Brandon 🙂


    On Thu, Jul 12, 2012 at 6:11 PM, Suzanne Napoleon <
    SuzanneNapoleon@fosiexpert.com> wrote:

    > Nothing gets saved with that.
    > Suzanne
    >
    1-Visitor
    July 12, 2012
    I tried#XPATHNODESET, but it didn't save anything either. I'm surprised, because I have examples in my book of#XPATHNODESET ad#XPATHCONTENT that return tags. However, this situation is different. In the book I am just trying to demonstrate the markup that FOSI will format.

    I tried following-sibling::title[1][.], which saves the text but not the <brk>.

    I wish I could do this with FOSI. An unusual combination of markup and formatting requirements has me stumped. However, writing this up got me thinking about something to look into with FOSI.

    Thanks everyone!

    Suzanne



    >----------
    >>