Skip to main content
1-Visitor
May 21, 2012
Question

alternate row shading

  • May 21, 2012
  • 18 replies
  • 6322 views
Dear Adepters,

We are using tables, based on Oasis models (in a DTD).
Is there a way to alternate row shading in tables display ? Maybe using 'tabstyle' attribute of <table>, Fosi (we have one) or Processing Instructions ?

Thanks for your answers,

Sébastien

    18 replies

    1-Visitor
    May 21, 2012
    You can set a counter on row and then do a #FOSI test on that counter and apply shading if rowct=1.

    1-Visitor
    May 21, 2012
    Not where I can input the code and test, so not saying anything definitive, but...

    Wouldn't there need to be something that checks whether rowct is even or odd, and only shade for one or the other? In order to shade alternate rows...
    ssauvage1-VisitorAuthor
    1-Visitor
    May 22, 2012
    Thanks for your answers.

    When coursing a row, I can check in an ACL function, knowing its index (counter) i, the value of i % 2 (0 or 1) to apply shading.
    But how in my Fosi can I apply shading to entire row (not cells one by one) ?

    Regards,

    Sébastien


    Le 22/05/2012 00:26, Steve Thompson a écrit:Not where I can input the code and test, so not saying anything definitive, but... Wouldn't there need to be something that checks whether rowct is even or odd, and only shade for one or the other? In order to shade alternate rows...
    ssauvage1-VisitorAuthor
    1-Visitor
    May 22, 2012
    I found a way to proceed in ACL (see code above), with Arbortext processing instructions.
    Does someone knows if I can do the same with Fosi, i.e without inserting processing instructions in XML content ?

    Thanks,
    Sébastien

    local $loidCaret = oid_caret();# should be a <table>
    local $loidArrChildren[];
    local $i = 0;
    local $loid = oid_null();
    local $loidChild = oid_null();
    local $lintCellId = 0;
    local $loidCellFont = oid_null();
    local $lintRowId = 0;
    local $lintRowIndex = 0;

    oid_find_children($loidCaret, $loidArrChildren, 'entry', 0x04);
    for ($i = 1; $i <= count($loidArrChildren); $i++)
    {
    $loid = $loidArrChildren[$i];

    # gets Cell Id
    $lintCellId = tbl_oid_cell($loid);
    # gets oid of cellfont pi, if any
    $loidCellFont = tbl_cell_fontpi($lintCellId, 'find');

    # gets row id
    $lintRowId = tbl_cell_row(lintCellId);
    # gets row index
    $lintRowIndex = tbl_row_index($lintRowId);

    if (($lintRowIndex % 2) == 1)
    {
    # creates cellfont pi if it does not exist
    if (!oid_valid($loidCellFont))
    {
    $loidCellFont = tbl_cell_fontpi($lintCellId, 'insert');
    }
    # modifies shading
    oid_modify_attr($loidCellFont, 'Shading', 'gray2');
    }
    else
    {
    tbl_cell_fontpi($lintCellId, 'delete');
    }
    }
    }

    Le 22/05/2012 10:28, Sébastien Sauvage a écrit:Thanks for your answers.

    When coursing a row, I can check in an ACL function, knowing its index (counter) i, the value of i % 2 (0 or 1) to apply shading.
    But how in my Fosi can I apply shading to entire row (not cells one by one) ?

    Regards,

    Sébastien


    Le 22/05/2012 00:26, Steve Thompson a écrit:Not where I can input the code and test, so not saying anything definitive, but... Wouldn't there need to be something that checks whether rowct is even or odd, and only shade for one or the other? In order to shade alternate rows...
    1-Visitor
    May 22, 2012
    HiSébastien!

    The PI for shading is inserted in <entry> tags, so it must be applied to <entry> rather than <row>.In the FOSI fragment below, the e-i-c for entry calls an ACL function named oddeven, which determines whether to insert the PI for shading.

    Hope this helps! Please let me know any questions you may have.


    Best regards,
    Suzanne Napoleon
    Suzanne Napoleon@FOSIexpert.com
    "WYSIWYG is last-century technology!"

    <counter initial="0" style="arabic" enumid="rowct">

    <e-i-c gi="row">
    <charlist inherit="1" charsubsetref="block">
    <enumerat increm="1" enumid="rowct">
    </charlist>
    </e-i-c>

    <e-i-c gi="entry" context="row">
    <charlist inherit="1"></charlist>
    <att>
    <specval attname="oddeven" attloc="SYSTEM-FUNC" attval="even">
    <charsubset>
    <usetext source="!&lt;?Pub _cellfont Shading="gray"?&gt;!"></usetext>

    </charsubset>
    </att>
    </e-i-c>


    1-Visitor
    April 20, 2018

    When I try this I am getting an error at the gray word, because the quote before it close the source string ... if I change to a single quote arround the gray word, it inserts the tag, but it is displayed as text ... Is my FOSI configured wrong?

    Also, if I change the &lt; and &gt; to '<' and '>', the tag is not displayed, but it does not render either ...

     


    @ptc-1908075 wrote:
    HiSébastien!

    The PI for shading is inserted in <entry> tags, so it must be applied to <entry> rather than <row>.In the FOSI fragment below, the e-i-c for entry calls an ACL function named oddeven, which determines whether to insert the PI for shading.

    Hope this helps! Please let me know any questions you may have.


    Best regards,
    Suzanne Napoleon
    Suzanne Napoleon@FOSIexpert.com
    "WYSIWYG is last-century technology!"

    <counter initial="0" style="arabic" enumid="rowct">

    <e-i-c gi="row">
    <charlist inherit="1" charsubsetref="block">
    <enumerat increm="1" enumid="rowct">
    </charlist>
    </e-i-c>

    <e-i-c gi="entry" context="row">
    <charlist inherit="1"></charlist>
    <att>
    <specval attname="oddeven" attloc="SYSTEM-FUNC" attval="even">
    <charsubset>
    <usetext source="!&lt;?Pub _cellfont Shading="gray"?&gt;!"></usetext>

    </charsubset>
    </att>
    </e-i-c>



     

    ssauvage1-VisitorAuthor
    1-Visitor
    May 23, 2012
    Hello Suzanne.

    Thank you for your response. It sounds very close to what I need.
    In what you offer:
    How to tell the FOSI to not insert text depending on the function return (typically 0 or 1). Is it with the value of "even" in your example ?How does the called ACL function know the context (oid ofentry element, rowct of row containing entry)?Sincerely,
    Sébastien


    Le 22/05/2012 19:15, Suzanne Napoleon a écrit:HiSébastien!
    The PI for shading is inserted in <entry> tags, so it must be applied to <entry> rather than <row>.In the FOSI fragment below, the e-i-c for entry calls an ACL function named oddeven, which determines whether to insert the PI for shading.
    Hope this helps! Please let me know any questions you may have.

    Best regards,Suzanne NapoleonSuzanne Napoleon@FOSIexpert.com "WYSIWYG is last-century technology!"
    <counter initial="0" style="arabic" enumid="rowct">
    <e-i-c gi="row"><charlist inherit="1" charsubsetref="block"><enumerat increm="1" enumid="rowct"></charlist></e-i-c>
    <e-i-c gi="entry" context="row"><charlist inherit="1"></charlist><att><specval attname="oddeven" attloc="SYSTEM-FUNC" attval="even"><charsubset><usetext source="!&lt;?Pub _cellfont Shading="gray"?&gt;!"></usetext>
    </charsubset></att></e-i-c>
    ssauvage1-VisitorAuthor
    1-Visitor
    May 23, 2012
    It's me again !

    I found a few responses.
    I've made an ACL function in a package called zzTables;
    function testOK($win, $oid)
    {
    eval "call of testOK with win: $win and oid: $oid" output=>*;
    return "1";
    }
    I updated my Fosi file with block:
    <att>
    <specval attname="zzTables::testOK" attloc="SYSTEM-FUNC" attval="1">
    <charsubset>
    <usetext source="!&lt;?Pub _cellfont Shading="gray5"?&gt;!"></usetext>
    </charsubset>
    </att>
    But I have two sections for "entry":
    one declared as this : <e-i-c gi="entry"> ...
    an other as this : <e-i-c gi="entry" context="thead" *=" row&quot;="> ...
    If I put the block in first section, function is called but shading is not applied ...
    If I put it in second block, function is not called ...

    I feel I'm near but I'm missing something.

    Thanks for your help,
    Sébastien



    Le 23/05/2012 14:39, Sébastien Sauvage a écrit:Hello Suzanne.

    Thank you for your response. It sounds very close to what I need.
    In what you offer:
    How to tell the FOSI to not insert text depending on the function return (typically 0 or 1). Is it with the value of "even" in your example ?How does the called ACL function know the context (oid ofentry element, rowct of row containing entry)?Sincerely,
    Sébastien


    Le 22/05/2012 19:15, Suzanne Napoleon a écrit:HiSébastien!
    The PI for shading is inserted in <entry> tags, so it must be applied to <entry> rather than <row>.In the FOSI fragment below, the e-i-c for entry calls an ACL function named oddeven, which determines whether to insert the PI for shading.
    Hope this helps! Please let me know any questions you may have.

    Best regards,Suzanne NapoleonSuzanne Napoleon@FOSIexpert.com "WYSIWYG is last-century technology!"
    <counter initial="0" style="arabic" enumid="rowct">
    <e-i-c gi="row"><charlist inherit="1" charsubsetref="block"><enumerat increm="1" enumid="rowct"></charlist></e-i-c>
    <e-i-c gi="entry" context="row"><charlist inherit="1"></charlist><att><specval attname="oddeven" attloc="SYSTEM-FUNC" attval="even"><charsubset><usetext source="!&lt;?Pub _cellfont Shading="gray"?&gt;!"></usetext>
    </charsubset></att></e-i-c>
    1-Visitor
    May 23, 2012
    Try

    return 1

    without quotes.

    OR try changing your test to

    attval to "#EQ#\1\"

    You may be getting a string vs. number mismatch.

    (I like the former if this is the issue.)


    You look very close, though. For what it's worth, here's an ACL we call
    from the root element as a system-func to check whether or not to use a US
    Letter or A4 collection of pagesets.


    function us_letter_exists(win,oid) {
    local exists = "no";
    if (oid_xpath_boolean($oid,'/descendant::us_letter')) {
    exists = "yes";
    } # if
    return exists
    } # us_letter_exists


    On Wed, May 23, 2012 at 6:17 AM, Sébastien Sauvage <sebastien.sauvage@c-s.fr<br/>> wrote:

    > It's me again !
    >
    > I found a few responses.
    > I've made an ACL function in a package called zzTables;
    > function testOK($win, $oid)
    > {
    > eval "call of testOK with win: $win and oid: $oid" output=>*;
    > return "1";
    > }
    > I updated my Fosi file with block:
    > <att>
    > <specval attname="zzTables::testOK" attloc="SYSTEM-FUNC" attval="1">
    > <charsubset>
    > <usetext source="!&lt;?Pub _cellfont Shading="gray5"?&gt;!"></usetext>
    > </charsubset>
    > </att>
    > But I have two sections for "entry":
    >
    > - one declared as this : <e-i-c gi="entry"> ...
    > - an other as this : <e-i-c gi="entry" context="thead" *=" row&quot;="> ...
    >
    > If I put the block in first section, function is called but *shading is
    > not applied* ...
    > If I put it in second block, function is not called ...
    >
    > I feel I'm near but I'm missing something.
    >
    > Thanks for your help,
    > Sébastien
    >
    >
    >
    > Le 23/05/2012 14:39, Sébastien Sauvage a écrit :
    >
    > Hello Suzanne.
    >
    > Thank you for your response. It sounds very close to what I need.
    > In what you offer:
    >
    > - How to tell the FOSI to not insert text depending on the function
    > return (typically 0 or 1). Is it with the value of "even" in your
    > example ?
    > - How does the called ACL function know the context (oid of entry
    > element, rowct of row containing entry)?
    >
    > Sincerely,
    > Sébastien
    >
    >
    > Le 22/05/2012 19:15, Suzanne Napoleon a écrit :
    >
    > Hi Sébastien!
    >
    > The PI for shading is inserted in <entry> tags, so it must be applied to
    > <entry> rather than <row>. In the FOSI fragment below, the e-i-c for
    > entry calls an ACL function named oddeven, which determines whether to
    > insert the PI for shading.
    >
    > Hope this helps! Please let me know any questions you may have.
    >
    > Best regards,
    > Suzanne Napoleon
    > Suzanne Napoleon@FOSIexpert.com
    > "WYSIWYG is last-century technology!"
    >
    > <counter initial="0" style="arabic" enumid="rowct">
    >
    > <e-i-c gi="row">
    > <charlist inherit="1" charsubsetref="block">
    > <enumerat increm="1" enumid="rowct">
    > </charlist>
    > </e-i-c>
    >
    > <e-i-c gi="entry" context="row">
    > <charlist inherit="1"></charlist>
    > <att>
    > <specval attname="oddeven" attloc="SYSTEM-FUNC" attval="even">
    > <charsubset>
    > <usetext source="!&lt;?Pub _cellfont Shading="gray"?&gt;!"></usetext>
    > </charsubset>
    > </att>
    > </e-i-c>
    >
    ssauvage1-VisitorAuthor
    1-Visitor
    May 23, 2012
    Thanks Paul.
    I've tried return 1 and return "1". It leads to the same result : function is called (tested with an eval call) but shading is not applied (i.e. processing instruction is not inserted by FOSI).

    Regards,
    Sébastien



    Le 23/05/2012 18:04, Paul Nagai a écrit:Try

    return 1

    without quotes.

    OR try changing your test to

    attval to "#EQ#\1\"

    You may be getting a string vs. number mismatch.

    (I like the former if this is the issue.)


    You look very close, though. For what it's worth, here's an ACL we call from the root element as a system-func to check whether or not to use a US Letter or A4 collection of pagesets.


    function us_letter_exists(win,oid) {
    local exists = "no";
    if (oid_xpath_boolean($oid,'/descendant::us_letter')) {
    exists = "yes";
    } # if
    return exists
    } # us_letter_exists


    On Wed, May 23, 2012 at 6:17 AM, Sébastien Sauvage <sebastien.sauvage@c-s.fr> wrote:
    It's me again !

    I found a few responses.
    I've made an ACL function in a package called zzTables;
    function testOK($win, $oid)
    {
    eval "call of testOK with win: $win and oid: $oid" output=>*;
    return "1";
    }
    I updated my Fosi file with block:
    <att>
    <specval attname="zzTables::testOK" attloc="SYSTEM-FUNC" attval="1">
    <charsubset>
    <usetext source="!&lt;?Pub _cellfont Shading="gray5"?&gt;!"></usetext>
    </charsubset>
    </att>
    But I have two sections for "entry":
    one declared as this : <e-i-c gi="entry"> ...
    an other as this : <e-i-c gi="entry" context="thead" *=" row&quot;="> ...
    If I put the block in first section, function is called but shading is not applied ...
    If I put it in second block, function is not called ...

    I feel I'm near but I'm missing something.

    Thanks for your help,
    Sébastien



    Le 23/05/2012 14:39, Sébastien Sauvage a écrit:Hello Suzanne.

    Thank you for your response. It sounds very close to what I need.
    In what you offer:
    How to tell the FOSI to not insert text depending on the function return (typically 0 or 1). Is it with the value of "even" in your example ?How does the called ACL function know the context (oid ofentry element, rowct of row containing entry)?Sincerely,
    Sébastien


    Le 22/05/2012 19:15, Suzanne Napoleon a écrit:HiSébastien!
    The PI for shading is inserted in <entry> tags, so it must be applied to <entry> rather than <row>.In the FOSI fragment below, the e-i-c for entry calls an ACL function named oddeven, which determines whether to insert the PI for shading.
    Hope this helps! Please let me know any questions you may have.

    Best regards,Suzanne NapoleonSuzanne Napoleon@FOSIexpert.com "WYSIWYG is last-century technology!"
    <counter initial="0" style="arabic" enumid="rowct">
    <e-i-c gi="row"><charlist inherit="1" charsubsetref="block"><enumerat increm="1" enumid="rowct"></charlist></e-i-c>
    <e-i-c gi="entry" context="row"><charlist inherit="1"></charlist><att><specval attname="oddeven" attloc="SYSTEM-FUNC" attval="even"><charsubset><usetext source="!&lt;?Pub _cellfont Shading="gray"?&gt;!"></usetext>
    </charsubset></att></e-i-c>
    1-Visitor
    May 23, 2012
    My next strategy would be to try calling it from something very simple
    (maybe <para>) and applying a color to be sure you've got everything right
    and that the only thing you're fighting is the table row logic. If you can
    get para working, then apply color to a cell. Then see if you can get it to
    alternate. Then try the shading PI.

    Or some similar simplification of the problems at hand.

    On Wed, May 23, 2012 at 9:18 AM, Sébastien Sauvage <sebastien.sauvage@c-s.fr<br/>> wrote:

    > Thanks Paul.
    > I've tried return 1 and return "1". It leads to the same result :
    > function is called (tested with an eval call) but shading is not applied
    > (i.e. processing instruction is not inserted by FOSI).
    >
    > Regards,
    > Sébastien
    >
    >
    >
    > Le 23/05/2012 18:04, Paul Nagai a écrit :
    >
    > Try
    >
    > return 1
    >
    > without quotes.
    >
    > OR try changing your test to
    >
    > attval to "#EQ#\1\"
    >
    > You may be getting a string vs. number mismatch.
    >
    > (I like the former if this is the issue.)
    >
    >
    > You look very close, though. For what it's worth, here's an ACL we call
    > from the root element as a system-func to check whether or not to use a US
    > Letter or A4 collection of pagesets.
    >
    >
    > function us_letter_exists(win,oid) {
    > local exists = "no";
    > if (oid_xpath_boolean($oid,'/descendant::us_letter')) {
    > exists = "yes";
    > } # if
    > return exists
    > } # us_letter_exists
    >
    >
    > On Wed, May 23, 2012 at 6:17 AM, Sébastien Sauvage <
    > sebastien.sauvage@c-s.fr> wrote:
    >
    >> It's me again !
    >>
    >> I found a few responses.
    >> I've made an ACL function in a package called zzTables;
    >> function testOK($win, $oid)
    >> {
    >> eval "call of testOK with win: $win and oid: $oid" output=>*;
    >> return "1";
    >> }
    >> I updated my Fosi file with block:
    >> <att>
    >> <specval attname="zzTables::testOK" attloc="SYSTEM-FUNC" attval="1">
    >> <charsubset>
    >> <usetext source="!&lt;?Pub _cellfont Shading="gray5"?&gt;!"></usetext>
    >> </charsubset>
    >> </att>
    >> But I have two sections for "entry":
    >>
    >> - one declared as this : <e-i-c gi="entry"> ...
    >> - an other as this : <e-i-c gi="entry" context="thead" *=" row&quot;="> ...
    >>
    >> If I put the block in first section, function is called but *shading is
    >> not applied* ...
    >> If I put it in second block, function is not called ...
    >>
    >> I feel I'm near but I'm missing something.
    >>
    >> Thanks for your help,
    >> Sébastien
    >>
    >>
    >>
    >> Le 23/05/2012 14:39, Sébastien Sauvage a écrit :
    >>
    >> Hello Suzanne.
    >>
    >> Thank you for your response. It sounds very close to what I need.
    >> In what you offer:
    >>
    >> - How to tell the FOSI to not insert text depending on the function
    >> return (typically 0 or 1). Is it with the value of "even" in your
    >> example ?
    >> - How does the called ACL function know the context (oid of entry
    >> element, rowct of row containing entry)?
    >>
    >> Sincerely,
    >> Sébastien
    >>
    >>
    >> Le 22/05/2012 19:15, Suzanne Napoleon a écrit :
    >>
    >> Hi Sébastien!
    >>
    >> The PI for shading is inserted in <entry> tags, so it must be applied
    >> to <entry> rather than <row>. In the FOSI fragment below, the e-i-c for
    >> entry calls an ACL function named oddeven, which determines whether to
    >> insert the PI for shading.
    >>
    >> Hope this helps! Please let me know any questions you may have.
    >>
    >> Best regards,
    >> Suzanne Napoleon
    >> Suzanne Napoleon@FOSIexpert.com
    >> "WYSIWYG is last-century technology!"
    >>
    >> <counter initial="0" style="arabic" enumid="rowct">
    >>
    >> <e-i-c gi="row">
    >> <charlist inherit="1" charsubsetref="block">
    >> <enumerat increm="1" enumid="rowct">
    >> </charlist>
    >> </e-i-c>
    >>
    >> <e-i-c gi="entry" context="row">
    >> <charlist inherit="1"></charlist>
    >> <att>
    >> <specval attname="oddeven" attloc="SYSTEM-FUNC" attval="even">
    >> <charsubset>
    >> <usetext source="!&lt;?Pub _cellfont Shading="gray"?&gt;!"></usetext>
    >> </charsubset>
    >> </att>
    >> </e-i-c>
    >>
    >