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

Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X

Triggering an attribute rule by matching counter/variable values

JasonBuss
1-Newbie

Triggering an attribute rule by matching counter/variable values

Hi all,

I am working on a scenario where I am trying to affect formatting for
e-i-cs that have an attribute value that matches an attribute value from
the root element (like change indication).

For example:

<root user="1">
<sub user="2">
SAMPLE TEXT
</sub>
<sub user="1">
SAMPLE TEXT <-- chgmark here
</sub>
<sub user="3">
SAMPLE TEXT
</sub>
</root>

I had some notes and sample code working at one time on how to do this.
Now that I finally have the time and support to see this through on one
of our FOSI updates, I cannot find this code locally anymore (lost my
HDD a year ago), and I can't locate where I had backed this up on our
network (this was a REALLY long time ago).

I searched the archives, and found a lot of close threads, but not the
one that gets me over the hump (the "matching attribute values" part).

I tried setting counters with the root and sub "user" att value, but I
can't remember how the heck I got them to "match" their values to
trigger attrule formatting (I seem to vaguely remember having a specval
and fillval in the same attribute rule, and their might have been more
than one attribute rule required to make this work, like one to
initialize/set, and the next actually triggered the chgmark).

I really hate losing stuff. And I REALLY hate getting old and not being
able to remember filenames to do a search...

Thanks in advance...

-Jason A. Buss
28 REPLIES 28


Like this maybe?

<e-i-c gi="sub">
<charlist></charlist>
<att>
<specval attname="user" attloc="root" attval="1">
<charsubset>
<chgmark barthick="3pt" baroffset="9pt" type="content"></chgmark>
<usetext source="\\" placemnt="after"></usetext>
</charsubset>
<att>
<att>
<specval attname="user" attval="1">
<charsubset>
<chgmark barthick="3pt" baroffset="9pt" type="content"></chgmark>
<usetext source="\\" placemnt="after"></usetext>
</charsubset>
<att>

</e-i-c>

-Andy

\ / Andy Esslinger LM Aero Tech Order Data
_____-/\-_____ (817) 279-0442 Box 748, Mail Zone 4285
\_\/_/ (817) 777 3047 Ft. Worth, TX 76101-0748



Oops, I think I may have over-simplified the example...



In practice, the user attribute can be any combination of up to 5 digits, so coding all the possible combinations as literal values won't work.



I can save both atts to a root-user.txt and sub-user.txt variable, but I need some way of saying:



<e-i-c gi="sub">
<charlist></charlist>

<att>
<specval attname="sub-user.txt" attloc="#FOSI" attval="root-user.txt">

<charsubset>
<chgmark barthick="3pt" baroffset="9pt" type="content"></chgmark>
<usetext source="\\" placemnt="after"></usetext>
</charsubset>
<att>

</e-i-c>



I know this is possible, I did it once before. I just can't remember how, and I can't find my old code samples. I hate it when you're asked to do something, and when you finished, you're asked to hang on to that until several PCs and servers later.



-J


Hi Jason?



Some of the FOSI gurus around here may have better ideas (this kind of
FOSI-fu is beyond my ken), but here are a couple of things that might work:



1) If you can use XPath expressions, it should be a piece of cake. For
a match, it would be something like ?sub[@user = /root/@user]?; for a
nonmatch, just negate the predicate: ?sub[not(@user = /root/@user)]?

2) You could always use a FOSI system-func call and do the test in an
ACL function



HTH.



--Clay



Clay Helberg

Senior Consultant

TerraXML


I can't provide a sample immediately (I am on a conference call as well as reading e-mail) but I think that the new XPath feature in FOSIs can be used to do this, assuming you are using a reasonably recent version of our software.

John Dreystadt
Software Development Director
Arbortext - PTC
734-352-2835
-

I can imagine working this with a system-func. Would that fly? Something
like:

youracl.acl (stored in editinit):
----
package youracl
function yourfunction (
usermatch = "no";
if (oid_attr(oid_root(),"user") == oid_attr(oid,"user")) {
usermatch = "yes";
}
return usermatch;
}
----
Then your att/specval is:
<specval attname="youracl::yourfunction" attloc="system-func" attval="yes">

Of course, this is cheating ... 😉


Jason,

I think SYSTEM-FUNC is what you need.Check out help 1325.

The FOSI code would be:

<e-i-c gi="sub">
<charlist></charlist>
<att>
<specval attname="MaybeChgmark" attloc="SYSTEM-FUNC" attval="1">
<charsubset>
<chgmark barthick="3pt" baroffset="9pt" type="content"></chgmark>
<usetext source="\\" placemnt="after"></usetext>
</charsubset>
<att>
</e-i-c>

You would need an ACL function:

function MaybeChgmark(window, oid)

that returns 1 if the two attribute values match. I'm thinking it's probably easiest to use ACL in the MaybeChgmarkfunction to test the attribute values in the document rather than test FOSI strings.

Good luck!
Suzanne Napoleon
"WYSIWYG is last-century technology!"
www.fosiexpert.com


System-func sounds like my brute-force option, but I think I'll give the Xpath expression a spin, see if it works.



I'll keep you all posted if/when I get this working.



Thanks all!



-Jason


Heh, great minds think alike... 🙂



Clay Helberg

Senior Consultant

TerraXML


system-func can be dangerous, performance-wise. I forget the condition/s
where it happens, but if implemented in just the right, strike that, wrong
way, it can bring your processor to its knees.

Jason,

No guarantees, as I don't have a license to test this out with. Having used a savetext to save the value of the user attribute on the root element to root-user.txt, try:

<e-i-c gi="sub">
<charlist></charlist>
<att>
<specval attname="user" attval="#EQ#root-user.txt">
<charsubset>
<chgmark barthick="3pt" baroffset="9pt" type="content"></chgmark>
<usetext source="\\" placemnt="after"></usetext>
</charsubset>
<att>
</e-i-c>

-Brandon 🙂

Brandon, that's what I thought about using, too. However, I can't find
any samples or examples of using #EQ# with a variable name. You can use
it with a literal (#EQ#\blah\) or a number (#EQ#4), but I've never seen
it used with a variable name. I am not sure that FOSI can do this.
Maybe Suzanne Napolean would know, if she reads this.

I don't know if we ever used this with a savetext variable or not. If a regex search like "#..#[^0-9\\]" in the regular FOSIs doesn't find anything, see if you can dig up the technical bulletin FOSI, as I think I was playing with some stuff along these lines in there.

In any case, help 544 (specval) says:

"#XX#YYY may be used for attributes whose declared value is a number where XX is one of the letter pairs LT, GT, EQ, LE, GE, NE and YYY is a numeric constant or an enumid (counter id). In this case, the specval will be satisfied if the value assigned to the given source document attribute is, respectively, less than, greater than, equal to, less than or equal to, greater than or equal to, or not equal to the given numeric constant or current value of the given counter.

The same syntax may be used for attributes whose declared value is not a number. In this case YYY is a backslash delimited literal or a textid (savetext name). If XX is a numerical operator (LT, GT, LE, GE), the two strings are compared character by character using the ordering of the default character set. It is safer to stick to the EQ and NE operators when comparing strings."

Jason, let me know if this works or not. If it doesn't, I've got an idea for an alternative approach involving baling wire, chewing gum and #XREF. 😉

-Brandon 🙂


I have an example: This one is used in my FOSI to mtest the value of a
string variable; subparatitle.appear.tdv is the variable name and there
are possible values for it of "yes" or "no" set elsewhere in the FOSI:

<specval attname="subparatitle.appear.tdv" attloc="#FOSI"&lt;br"/>attval="#EQ#\no\">



-Andy
\ / Andy Esslinger LM Aero Tech Order Data
_____-/\-_____ (817) 279-0442 Box 748, Mail Zone 4285
\_\/_/ (817) 777 3047 Ft. Worth, TX 76101-0748

The following worked for me. Note that you needthe stringdecl for root-user.txt or you get an error message.

<stringdecl textid="root-user.txt" literal="">
...

<e-i-c gi="root">
...
<att>
<fillval attname="user" attloc="root" fillcat="savetext" fillchar="conrule">
<charsubset>
<savetext textid="root-user.txt"></charsubset>
</att>
...

<e-i-c gi="sub">
...
<att>
<specval attname="user" attloc="sub" attval="#EQ#root-user.txt">
<charsubset>
<usetext source="\matches!\"></usetext>
</charsubset>
</att>
...

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


I should have looked at the help before replying. I was thinking of the
GE, GT, LT and LE values. Those can only compare numbers, but EQ is
usable for strings.

Paul likes this. (ok, too much facebook time ...)

On Thu, Apr 16, 2009 at 11:00 AM, Suzanne Napoleon <
SuzanneNapoleon@fosiexpert.com> wrote:

> The following worked for me. Note that you need the stringdecl for
> root-user.txt or you get an error message.
>
> <stringdecl textid="root-user.txt" literal="">
> ...
>
> <e-i-c gi="root">
> ...
> <att>
> <fillval attname="user" attloc="root" fillcat="savetext"&lt;br"/>> fillchar="conrule">
> <charsubset>
> <savetext textid="root-user.txt"></charsubset>
> </att>
> ...
>
> <e-i-c gi="sub">
> ...
> <att>
> <specval attname="user" attloc="sub" attval="#EQ#root-user.txt">
> <charsubset>
> <usetext source="\matches!\"></usetext>
> </charsubset>
> </att>
> ...
>
> Suzanne
> "WYSIWYG is last-century technology!"
> www.FOSIexpert.com
>
>

Ok, I got sucked into a vendor demo that went way long yesterday...



I did try the #EQ#textid and it worked.



Thank goodness. After reading Paul's response about performance hits
when using system-func, I was looking for any other option.



This is clearly the most elegant solution. For reference, I did try
this with a counter id instead of a text variable and got nothing (I
enumerated the counter on the e-i-c to set/initialize to my comparison
value). I guess it seems odd that with the #FOSI loc set, the attname
will take both counter or string id, but the #XX# modifier only worked
with string ids for the specval value.



I did some looking around for methods using Xpath, but the only thing I
found was the "Xpath" attribute for the e-i-c, and no supporting
documentation (I am using 5.3 M040). I did see some info in the help
center, but it looks like it's all tied to Styler and the Generated Text
Dialog (still grokking FOSI with Crimson Editor). I looked at the
release notes for M120, didn't see anything jump out as far as Xpath
functionality added to FOSI. Does anyone know what Xpath support for
FOSI John was referencing, and is it even available back in M040?



Anyway, thanks for the help all!



If the adepters.org site is still active, I could post this solution
there for future reference...



-Jason


Adepters.org is active.

Sent from my iPhone

On Apr 17, 2009, at 7:23 AM, "Buss, Jason A"
<jabuss@cessna.textron.com> wrote:

> Ok, I got sucked into a vendor demo that went way long yesterday…
>
>
>
> I did try the #EQ#textid and it worked.
>
>
>
> Thank goodness. After reading Paul’s response about performance hit
> s when using system-func, I was looking for any other option.
>
>
>
> This is clearly the most elegant solution. For reference, I did try
> this with a counter id instead of a text variable and got nothing (I
> enumerated the counter on the e-i-c to set/initialize to my
> comparison value). I guess it seems odd that with the #FOSI loc
> set, the attname will take both counter or string id, but the #XX#
> modifier only worked with string ids for the specval value.
>
>
>
> I did some looking around for methods using Xpath, but the only
> thing I found was the “Xpath” attribute for the e-i-c, and no
> supporting documentation (I am using 5.3 M040). I did see some info
> in the help center, but it looks like it’s all tied to Styler and t
> he Generated Text Dialog (still grokking FOSI with Crimson Editor).
> I looked at the release notes for M120, didn’t see anything jump ou
> t as far as Xpath functionality added to FOSI. Does anyone know wha
> t Xpath support for FOSI John was referencing, and is it even availa
> ble back in M040?
>
>
>
> Anyway, thanks for the help all!
>
>
>
> If the adepters.org site is still active, I could post this solution
> there for future reference…
>
>
>
> -Jason
>
>
>

This is exactly the sort of FOSI-fu I knew probably existed but was
beyond me. I agree that this is more elegant, and no doubt more
efficient, than using SYSTEM-FUNC. I'm filing this one away for future
reference. Thanks to Brandon and Suzanne for putting it all together.



--Clay


Don't be afraid of system-func, just respectful 😉

If you're going to have performance problems, you'll know as soon as you get
past the tiny-fragment testing phase into the well, let's throw one of our
bigger documents at it phase. The problems, when they occur are geometric,
not linear, in my experience, so there's no missing it ... it won't be the
sort of gotcha that will pop-up during a Friday at 9 p.m. production run and
surprise you.

That said, I try pretty hard to solve it another way if possible.


I’m not afraid of system-func, and I’ve used it in the past with reasonable success, but I also tend to avoid it if I can.



I’m looking forward to making my FOSI-fu stronger at PTC/USER this year.


Sorry it has taken me a long time to get back to this, lots of conference calls and other duties.

But here is a really short example of how you can use the relatively new xpath support in FOSIs.

<att>
<specval attname="@role=/*/@role" attloc="#xpath" attval="1"/">
<charsubset>


This will work in any version of 5.3.

General performance for XPath is pretty good. But you can code XPath expressions that walk the entire document and these run really slowly. So avoid "//" or other XPath constructs that walk long distances unless you know you are doing them a very small number of times.

John Dreystadt
Software Development Director
Arbortext - PTC
734-352-2835
-

Thanks, John, that's very cool. Another one to file away for future reference.

--Clay

<resists urge=" to=" chant=" &quot;clay's=" afraid=" of=" system-func!=" clay's=" afraid=" of=" system-func!&quot;=">

I agree; I think of system-func as a last-ditch "escape hatch" if nothing else works.

Regarding XPath in FOSIs, John's explanation of attloc="#xpath" was very informative (thanks, John!), as I wasn't aware of that (undocumented!) feature. For the rest of the (also undocumented) XPath support in FOSIs, you can take a look at doctypes\outstpec\outspec.dtd in the Editor distribution and search for "xpath". The comments actually provide pretty decent explanation for the feature as long as you already have basic familiarity with both FOSI and XPath.

And Clay, I've read the FOSI scroll. There is no secret ingredient. 😉

-Brandon 🙂

The FOSI Enumerat categoryhas an xpath characteristic. I couldn't find any documentation on it except a comment in the OutSpec DTD:


increm CDATA -- a (ATI: possibly negative) integer -- #IMPLIED
enumid IDREF -- an idref -- #IMPLIED
setvalue NUMBER -- ATI: 0,1,2 -- #IMPLIED
xpath CDATA -- if present, use xpath result instead
of increm -- #IMPLIED >

I tested it for mybook-in-progress on FOSI.Here's the example from the book:

<counter initial="1111" style="arabic" enumid="codect">
...
<e-i-c gi="document" code="123">
<charlist inherit="1">
<enumerat enumid="codect" xpath="string(@code)">
<usetext source="codect"></usetext>
...

The gentext is1234

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



I've used system-func in limited situations, without performance issues,
but yeah, it's my last resort if there's absolutely no way to get there
from here. I can tell you, if you have to zip up one appsave for PTC,
and you've got system-funcs in your FOSI, you gotta make sure you get
all your supporting ACL, makes for some overhead when reporting
issues...



I'll have to browse through the outspec DTD, I didn't find anything in
the help center, so apparently there's no documentation for Xpath in
FOSI (at least not as of M040).



Your will is strong, but your FOSI is weak...



Cheers!



-Jason


I testedthe following from the OutSpec and it worked. Code is below.

"#XX#YYY may be used for attributes whose declared value is a number where XX is one of the letter pairs LT, GT, EQ, LE, GE, NE and YYY is a numeric constant or an enumid (counter id). In this case, the specval will be satisfied if the value assigned to the given source document attribute is, respectively, less than, greater than, equal to, less than or equal to, greater than or equal to, or not equal to the given numeric constant or current value of the given counter."

DTD FRAGMENT


FOSI FRAGMENT
<counter initial="0" style="arabic" enumid="document-userct">
...
<e-i-c gi="root">
<charlist inherit="1"></charlist>
<att>
<fillval attname="user" attloc="root" fillcat="enumerat" fillchar="increm">
<charsubset>
<enumerat enumid="document-userct" setvalue="1">
</charsubset>
</att>
...
<e-i-c gi="sub">
<charlist inherit="1"></charlist>
<att>
<specval attname="user" attloc="sub" attval="#EQ#document-userct">
<charsubset>
<usetext source="\match!\"></usetext>
</charsubset>
</att>
...

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



I see where I went wrong... I used the setvalue in the fillchar instead
of increment. Sigh... My FOSI-fu is weak, as well. 🙂



Oh well. Have a good weekend, all!



-Jason


Top Tags