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

xpath equivalent of FOSI #CONTENT?

  • July 12, 2012
  • 24 replies
  • 4871 views

    24 replies

    1-Visitor
    July 13, 2012
    I wouldn't know about xpath, but what happens if you save to a TDV and then in <c> resave it to a TIV with placemnt="after"? (Put your "container" in an ATTR test for <c>).


    gi="a"
    <savetext textid=".b.tdv" conrule="" placemnt="before"">


    gi="b"
    <savetext textid=".b.tdv" conrule="#CONTENT">

    gi="c"
    <att> If is not empty:
    <specval attname="b.tdv" attloc="#FOSI" attval="#ANY">
    <savetext textid=".b.tiv" conrule="#CONTENT" append="0">


    <att> If is empty do this:
    <specval attname="b.tdv" attloc="#FOSI" attval="#NONE">
    <do whatever=" is=" appropriate=">

    If has a value it winds up in the TIV until reset by another occurrence of . You might set it up with a scope of <c>. I don't have time to actually play with this. I remember something like it in a long ago FOSI that I don't seem to have any more.

    -Andy
    \ / Andy Esslinger LM Aero - Tech Order Data
    _____-/\-_____ (817) 279-0442 1 Lockheed Blvd, MZ 4285
    \_\/_/ (817) 777-3047 Fort Worth, TX 76108-3916

    1-Visitor
    July 13, 2012
    The problem is there is no scoping element for b.tiv. It could be a pseudo-element, but must be in context of the same pseudo-element in order for<title> and to be output before .


    1-Visitor
    July 14, 2012
    Here's a tested-and-working version of what I initially proposed, using
    XPath. The e-i-c for "a" does the rearranging, while the ones for "title"
    and "b" just hide themselves, as appropriate.

    <e-i-c gi="a">
    <charlist inherit="1"></charlist>
    <att>
    <specval attname="PRINT-ONLY" attloc="system-var" attval="#ANY">
    <specval attname="following-sibling::b[1][string(.)]"&lt;br"/>attloc="#xpath" attval="1">
    <charsubset>
    <usetext<br/>source="#XPATHCONTENT(following-sibling::b[1])#XPATH"
    placemnt="before"></usetext>
    <usetext<br/>source="#XPATHNODESET(following-sibling::title[1])#XPATH"
    placemnt="before"></usetext>
    </charsubset>
    </att>
    </e-i-c>

    <e-i-c gi="title">
    <charlist inherit="1">
    <textbrk startln="0" endln="0"></charlist>
    <att>
    <specval attname="PRINT-ONLY" attloc="system-var" attval="#ANY">
    <specval attname="following-sibling::b[1][string(.)]"&lt;br"/>attloc="#xpath" attval="1">
    <charsubset>
    <suppress sup="1"></charsubset>
    </att>
    </e-i-c>

    <e-i-c gi="b">
    <charlist inherit="1">
    <textbrk startln="0" endln="0"></charlist>
    <att>
    <specval attname="PRINT-ONLY" attloc="system-var" attval="#ANY">
    <charsubset>
    <suppress sup="1"></charsubset>
    </att>
    </e-i-c>


    Now, by "a FOSI way", I'm guessing you mean "without using XPath", so
    here's that version. I assume an element called "abc" as the overall
    container for all this content (there's got to be something, even if it's
    the document element).

    If we can't save the "a" element within its own e-i-c, we can save
    everything from the parent and use a couple of counters to output the right
    "a" in a pass through the parent's content on each "c", at which point
    we'll know what was in "b". Separate text variables hold the content of
    each "title" and "b" for later output. Because we don't know in advance if
    we need to reorder or not, we basically end up doing it every time, even if
    there's really no change in the case where "b" is empty.

    First, the counters and variables. Note the initial="2" on one counter to
    make things match up, due to the timing mismatch involved when we're
    outputting at "c" the previous "a", with the counter being incremented by
    "b" in between.

    <counter initial="1" enumid="b.ct">
    <counter initial="2" enumid="b-psu.ct">
    <stringdecl textid="abc.txt">
    <stringdecl textid="title.txt">
    <stringdecl textid="b.txt">

    And here are the e-i-cs. Note that the context="a.psu" e-i-cs are just
    there to hide everything except the "a" we want on any given pass, based on
    the "b.ct" counter. If anything else might show up inside the "abc"
    element, additional e-i-cs of this type would be needed.

    <e-i-c gi="abc">
    <charlist>
    <reset resetlist="b.ct">
    <savetext textid="abc.txt"&lt;br"/>conrule="<a.psu>,#CONTENT,</a.psu>" placemnt="before">
    <savetext textid="b.txt" conrule="\\" placemnt="before">
    <savetext textid="title.txt" conrule="\\" placemnt="before"></charlist>
    </e-i-c>

    <e-i-c gi="a" context="abc">
    <charlist inherit="1"></charlist>
    <att>
    <specval attname="PRINT-ONLY" attloc="system-var" attval="#ANY">
    <charsubset>
    <suppress sup="1"></charsubset>
    </att>
    </e-i-c>

    <e-i-c gi="title" context="abc">
    <charlist inherit="1">
    <textbrk startln="0" endln="0">
    <savetext textid="title.txt" conrule="#CONTENT" placemnt="before">
    </charlist>
    <att>
    <specval attname="PRINT-ONLY" attloc="system-var" attval="#ANY">
    <charsubset>
    <suppress sup="1"></charsubset>
    </att>
    </e-i-c>

    <e-i-c gi="b" context="abc">
    <charlist inherit="1">
    <textbrk startln="0" endln="0">
    <enumerat increm="1" enumid="b.ct">
    <savetext textid="b.txt" conrule="#CONTENT" placemnt="before">
    </charlist>
    <att>
    <specval attname="PRINT-ONLY" attloc="system-var" attval="#ANY">
    <charsubset>
    <suppress sup="1"></charsubset>
    </att>
    </e-i-c>

    <e-i-c gi="c" context="abc">
    <charlist inherit="1">
    <textbrk startln="0" endln="1"></charlist>
    <att>
    <specval attname="PRINT-ONLY" attloc="system-var" attval="#ANY">
    <specval attname="b.txt" attloc="#FOSI" attval="#ANY">
    <charsubset>
    <usetext source="b.txt" placemnt="before"></usetext>
    <usetext source="title.txt" placemnt="before"></usetext>
    <usetext source="abc.txt" placemnt="before"></usetext>
    </charsubset>
    </att>
    <att>
    <specval attname="PRINT-ONLY" attloc="system-var" attval="#ANY">
    <specval attname="b.txt" attloc="#FOSI" attval="#NONE">
    <charsubset>
    <usetext source="abc.txt" placemnt="before"></usetext>
    <usetext source="title.txt" placemnt="before"></usetext>
    </charsubset>
    </att>
    </e-i-c>

    <e-i-c gi="a.psu">
    <charlist>
    <reset resetlist="b-psu.ct"></charlist>
    </e-i-c>

    <e-i-c gi="a" context="a.psu">
    <charlist>
    <suppress sup="1"></charlist>
    <att>
    <specval attname="b-psu.ct" attloc="#FOSI" attval="#EQ#b.ct">
    <charsubset>
    <suppress sup="0"></charsubset>
    </att>
    </e-i-c>

    <e-i-c gi="title" context="a.psu">
    <charlist>
    <suppress sup="1"></charlist>
    </e-i-c>

    <e-i-c gi="b" context="a.psu">
    <charlist>
    <suppress sup="1">
    <enumerat increm="1" enumid="b-psu.ct"></charlist>
    </e-i-c>

    <e-i-c gi="c" context="a.psu">
    <charlist>
    <suppress sup="1"></charlist>
    </e-i-c>

    -Brandon 🙂


    On Fri, Jul 13, 2012 at 5:16 PM, Suzanne Napoleon <
    SuzanneNapoleon@fosiexpert.com> wrote:

    > In this particular case, the markup seems to be insufficient for FOSI to
    > achieve the desired formatting. FOSI is best when there is a specific
    > context for everything, which isn't the case here.
    >
    > The SGML doc has:
    >
    > <title>TTT</title>BBB<c>CCC</c>
    >
    <title>TTT</title>BBB<c>CCC</c>
    >
    ...
    >
    > The formatting depends on whether element is empty or not. If has
    > content, the output should be:
    >
    > BBB TTT GRAPHIC CCC
    >
    > There is no container tag for the repeating markup
    , <title>, , and
    > <c>, so there is no scope for a time-independent variable.
    >
    > Also,
    is a singleton graphic, which means FOSI can't save 's
    > graphic for output later. If
    had a container (such as <figue> with
    > <graphic>), savetext on the container e-i-c would save the graphic for
    > output later. Using a pseudo-element for a container for the graphic
    > element doesn't work.
    >
    > So I am resorting to xpath in the e-i-c for
    to get the content of
    > <title> and . It was working until <brk> tags were inserted in <title>.
    > What is needed for the xpath is the equivalent of FOSI #CONTENT to save
    > #PCDATA and any tags. I still have some things to try with that approach.
    >
    > On the other hand, if anyone can figure out a FOSI way to do this, I'll
    > definitely put you and it in my book!
    >
    > Thanks!
    > Suzanne
    >
    >
    1-Visitor
    August 24, 2012
    My apologies for the delay in following up on this.

    I ended up using XPath. As soon as I consulted my book, I realized usetext was needed, as Brandon suggested.

    Re: the FOSI approach, I tested the code Brandon provided and it worked. 🙂 I had been thinking about saving everything to a string and somehow using a counter to output the graphics one by one, but nothing specific was coming to me on the "somehow" part. Brandon's solution is perfect! It is such great stuff that I had to add it to my book. Note that Ifocused on the case when has content because it requires re-ordering the elements. Note that Brandon provided production-level code. The example in the book, however, tries to keep things short and sweet.

    PDF is attached. All feedback is welcome.

    Thanks!
    Suzanne Napoleon
    www.FOSIexpert.com
    "WYSIWYG is last-century technology!"