correct use of xppattr and attr()

I am struggling to get something to work and wondered if someone could point me in the right direction?

I need to call a XyPerl subroutine in the ::before tag to set something up which will allow me to alter whether the paragraph is centered or range left. There is a counter which is set that allows me to test and use an if / else statement so I can then use the xppattr to load different values.

Then I need to use the attr() function to the text-align property in the main para to change to the relevant value.

However everything I have tried, and believe me I have tried many things, does not seem to change anyhting.

Parents
  • First, it was never intended that the CSS 3 attr() function be used to set any and all CSS values using e.g. <foo font="Helvetica" text-align="-xpp-ragged-right" font-variant="small-caps" ...>.

    When a "string" value is used as the value-type of an argument to the CSS 3 attr() function, it is (or was) specified that the string value not be re-parsed by the CSS processor, it ends up being both ugly, error prone and inefficient.

    That said, it is perfectly reasonable that Chris wants to set text align to left or right depending on the value of an x-register.

    So why not this:

    sub check{

    . . .

    if ($notest == 1){

    $X->xppattr('align', 'string', '', 'center');

    } else {

    $X->xppattr('align', 'string', '', 'left');

    }

    and in the CSS

    para[xpp\:align='center'] { text-align: center; }

    para[xpp\:align='left'] { text-align: left; }

    In my opinion, this is a bit more readable than setting Fred to '9' or '10'.

    The real reason(s) for implementing the CSS 3 attr() function in XPP are:

    1) To address the "tabular problem in CSS", i.e. that fact that not all composition values are restored properly if you have e.g. a CALS table with an <entry> element with embedded tags which change e.g. text alignment, font weight, font size, and your t5 spec is setup to restore body/header c/p values on each <entry>. See cals_t5.css spec. By using the xppattr xymacro, it is possible to "save" composition values as attributes on the MLH (markup language header), and then you can set font-size, font-width, text-align using the CSS 3 attr() function.

    2) To facilitate QA testing, where you may want to specify c/p values using attributes for data-driven XML testing.

    3) For cases like Chris mentioned, as shown above.

    That's my 2p's worth, for today anyway.

    Tony

  • Thanks Tony for the detailed reply. This looks more elegant that using numbers so I will try this!

Reply Children
No Data