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

Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X

FOSI - function substr on an attribute value

ptc-1548727
1-Newbie

FOSI - function substr on an attribute value

Hello,



I would like to call an ACL function in a FOSI and use the result to find a tag (the result is the id of the tag to find).

My SGML file contains :



<para>

xxxx xx xxxxxxxxx

<xref xrefid="f001-g001-HOT001" xidtype="hotspot">,

xxx xx xx xxxxx xxxxxxxx xxxxx

<xref xrefid="f001" xidtype="figure">.

</para>

...

<figure id="f001" xxxx="xxxx"> xxx xxx </figure>





I would like to extract "f001" from the attribute xrefid="f001-g001-HOT001" (when xidtype is "hotspot") in order to print specific text found in the figure tag or specific counter incremented in the e-i-c of the figure tag.



I wrote the following function and declare it in the instance.acl but I don't know how to use it in my FOSI:



function extrfig(window,oid){

return substr(oid_attr(oid,"xrefid"),1,4);

}



Thanks.



Yves DENIARD
Systèmes d'Information Logistique
MBDA France
1, avenue Réaumur
92358 le Plessis-Robinson CEDEX
tél. : 01.71.54.27.39
mail : yves.deniard@mbda-systems.com <">mailto:yves.deniard@mbda.fr>



5 REPLIES 5

On Mon, Sep 1, 2008 at 8:01 AM, DENIARD.Yves
<yves.deniard@mbda-systems.com>wrote:

> Hello,
>
> I would like to call an ACL function in a FOSI and use the result to find a
> tag (the result is the id of the tag to find).
>
This an example of a specval function call from one of our FOSIs:
<specval attname="my_fosi_funcs::funcname" attloc="system-func"&lt;br"/>attval="Yes">

my_fosi_funcs.acl contains the function funcname (which returns Yes or No)
and is located in custom/editinit. It could also be stored in scripts and
sourced from something in custom/editinit. You want do do more than just a
boolean test so read on:

This is a fillval function call from another FOSI (the location of the ACL
and function is the same as with the boolean test example above):
<att>
<fillval attname="my_fosi_funcs::make4" attloc="system-func"&lt;br"/>fillcat="savetext" fillchar="conrule"/>
<charsubset>
<savetext textid="area.txt" placemnt="before"/"></charsubset>
</att>

This is the function:
function make4(win,oid) {
return substr((oid_content($oid) . chr(160) . chr(160) . chr(160) .
chr(160)), 1, 4);
}

This bad boy pads the savetext with training spaces to a length of 4.

Be careful with system-func's in FOSIs. It is possible to bring your CPU to
its figurative knees if called from the "wrong" element or context ...


--
Paul Nagai

Yves,

Can you tell us more about what you are trying to accomplish? It sounds like you want to capture the content of another element, which can be done without an ACL function.

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


<e-i-c gi="xref">
<att>
<fillval attname="mbda::processRef" attloc="system-func" fillcat="usetext" fillchar="source">
<charsubset>
<usetext></usetext>
</charsubset>
</att>
</e-i-c>

C:\Program Files\Arbortext\Epic\custom\editinit\mbda.acl

package mbda

function processRef() {}

function processRef(window, oid) {
# return if xidtype attr value != "hotspot"

# refid = substr(oid_attr(oid,"xrefid"),1,4)

# scan the document elements
# if id = refid then refContent = element content
# if not found then return

# goto_oid(oid)
# insert(refContent)
}

I neglected to add that I agree with Paul Nagai about being careful with system-funcs in a FOSI. For best performance, utilize FOSI whenever possible and resort to ACL only when there is no alternative. FOSI is compiled, which makes it faster than a run-time language such as XSL. However, FOSI attribute rules, including those with a system-func that calls ACL, are executed at run-time for each formatting pass, which slows down the formatting process (although ACL on its own can be very fast). BTW, dozens of attribute rules without system-func in an e-i-c can can slow formatting to a crawl, as well.


Good luck!
Suzanne


Thanks for all your answers (and questions because they also make me advance).

Yes I finally found a way to use only FOSI.

I finally understood how "fillval" works. It was the good solution :



Creating e-i-c hotspot :



<e-i-c gi="hotspot" context="figure">

<charlist></charlist>

<att>

<fillval attname="apsname" attloc="hotspot" fillcat="savetext" fillchar="conrule">

<charsubset>

<savetext textid="apsname.txt">

</charsubset>

</att>

<att>

<fillval attname="id" attloc="hotspot" fillcat="savetext" fillchar="textid">

<charsubset>

<savetext conrule="\(\,figct.txt,\," rep.=" \,apsname.txt,\)\&quot;=">

</charsubset>

</att>

</e-i-c>



And adding the e-i-c xref :



<att>

<specval attname="xidtype" attloc="xref" attval="hotspot">

<fillval attname="xrefid" attloc="xref" fillcat="usetext" fillchar="source">

</att>



Thanks to all of you.

Regards.



Yves DENIARD
Systèmes d'Information Logistique
MBDA France
1, avenue Réaumur
92358 le Plessis-Robinson CEDEX
tél. : 01.71.54.27.39
mail : yves.deniard@mbda-systems.com <">mailto:yves.deniard@mbda.fr>
Announcements