cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Styler 5.2 conditional logic

naglists
1-Newbie

Styler 5.2 conditional logic

Hi,

Does the following styler attribute test:
if attribute "landscape" of element "subhead" != "yes"

Include
if attribute "landscape" of element "subhead" is not assigned any value

I want to Stylerize this FOSI specval logic:
<specval attname="pgwide" attloc="system_response" attval="yes"/">
<specval attname="landscape" attloc="h1" attval="#NE#\yes\"/">
<specval attname="landscape" attloc="h2" attval="#NE#\yes\"/">
<specval attname="landscape" attloc="subhead" attval="#NE#\yes\"/">

I wrote one condition:
if attribute "pgwide"="yes" and if attribute "landscape" of element "h1" !=
"yes" and if attribute "landscape" of element "h2" != "yes" and if attribute
"landscape" of element "subhead" != "yes"

And the indent change for pgdwide does not get applied to <system_response<br/>pgwide="yes"> in <h1> where landscape is not set.

I accepted that I may have to write 7 conditions combing or permuting (I
could never remember which was which) the three possible landscape locations
(AAA, AAB, ABA, BAA, ABB, AAB, BBB) except written out like:

AAA: if attribute "pgwide"="yes" and if attribute "landscape" of element
"h1" != "yes" and if attribute "landscape" of element "h2" != "yes" and if
attribute "landscape" of element "subhead" != "yes"

AAB: if attribute "pgwide"="yes" and if attribute "landscape" of element
"h1" != "yes" and if attribute "landscape" of element "h2" != "yes" and if
attribute "landscape" of element "subhead" is not assigned any value

etc.

But, that didn't work either. Now I'm not sure what I'm doing ...

Does neither condition (!="yes" NOR "is not assigned a value") resolve as
true if an ancester element named in the condition is not an ancestor to the
system_response element being processed?

Was that English?

--
Paul Nagai
3 REPLIES 3

Oh man. I think I just answered my own question. I added an A test.
pgwide=yes, h1/@landscape is not set. It formatted properly.

I would have to write the seven combi/permu-tations for h1/h2/subhead, the
four combi/permu-tations for h1/h2, the four combi/permu-tations for
h1/subhead, and the two combi/permu-tations for h1. And I don't know what
I'd do about the fact that subhead can contain a subhead.

I'm back to one condition: pgwide=yes AND a paragraph in the writer's guide.
Well, easy for me today. Expensive for me when someone "figures this out"
during a production check and is sure it's a bug in the stylesheet.

Hey, Paul...

Sounds like you got something that works, but might not work for
different cases. I couldn't quite tell for sure from your description.

In any case, reading through your description of the problem made me
think of something you may want to consider. I don't know exactly how
Styler evaluates these conditions, but knowing that it allows a fair bit
of XPath in certain areas, I wonder if XPath rules might apply, here.
One thing to understand about XPath is that the expressions [@landscape
!= "yes"] and [not(@landscape = "yes")] can give different results.
Keep in mind that [@landscape] returns a node-set, which will contain
either zero nodes (if the "landscape" attribute is not specified on the
current element) or one node (if it is).

The expression [@landscape != "yes"] will be true if there is a
"landscape" attribute node whose string value (the value of the
attribute) is *not* equal to "yes". If there is no such attribute, the
expression will be false. The expression [not(@landscape = "yes")] will
be true if there is *not* a "landscape" attribute node whose string
value is equal to "yes". Note the slight difference in wording between
these two, as it is crucial. (Check out section 3.4 of the XPath 1.0
specification for all the details.)

If XPath semantics are at play with your Stylersheet, I can see why the
first expression would fail in the case where "landscape" is not set.
I'd try rewriting your condition as follows (up to you to translate this
from straight XPath back into Styler's syntax... still not using Styler,
here):

@pgwide = "yes" and not(ancestor::h1/@landscape = "yes") and
not(ancestor::h2/@landscape = "yes") and
not(ancestor::subhead/@landscape = "yes")

Hope this helps. Let me know if my crystal clear explanation got a
little muddy on its way through the email system. 😉

Brandon Ibach
Lockheed Martin Space Systems
Cape Canaveral, FL
321-476-7051

On Mon, Apr 7, 2008 at 4:20 PM, Ibach, Brandon L <->
wrote:

> @pgwide = "yes" and not(ancestor::h1/@landscape = "yes") and
> not(ancestor::h2/@landscape = "yes") and not(ancestor::subhead/@landscape =
> "yes")
>
> Hope this helps. Let me know if my crystal clear explanation got a little
> muddy on its way through the email system. Smiley Wink
>

Hey Brandon,
That's a good idea and worth considering ... tomorrow ... when I'm not so
grumpy.

I try to weigh the complexity/supportability of various choices I make when
developing a stylesheet of any sort ... how easy/hard will it be for the
next person to figure out my code vs. how hard will it be for authors to
work within a set of rules not enforced by the DTD or authoring environment.
I may also have been able to solve the problem by creating contexts and
applying a less whacky set of conditions below each of those contexts, but
that didn't frankly feel any less confusing than the huge grid of conditions
I was working up to in my last post.

I'm still pondering a FOSI source edit. One att with four specvals does it,
but jumps out of the Styler interface ... 😕 Your XPATh solution (which
I've used in straight XSL stylesheets) stays within the Styler interface,
though, and would probably more accessible to some future me than FOSI
coding, so it's a strong candidate (and semi-respects not distracting
authors with formatting thoughts although it eliminates half the though ...
they are going to have already decided they need pgwide, now they just have
to understand if/when it becomes part of a landscape element it breaks)

Anyhow ... thanks for the idea.

--
Paul Nagai
Announcements