Skip to main content
1-Visitor
September 24, 2013
Question

savetext value with leading zeros and FOSI

  • September 24, 2013
  • 19 replies
  • 2833 views

Hi,


I am creating a print fosi for our tech authors to review content in a pdf form.


I have an element that requires a 3-digit numerical value per its DTD (which I can't alter) and am capturing its value with a savetext in order to output it later in the instance. That was fine, but now my authors want to see that number output without its leading zeros when they print a review copy if its value is less than 100, i.e., "98" not "098". Is there a way to strip those leading zeros out using FOSI?


Thanks, KM

    19 replies

    kmccain1-VisitorAuthor
    1-Visitor
    October 1, 2013

    Thanks again for your input. I followed your instructions - I updated my acl script as you suggested and added an attribute rule (to call the script and do the savetext) to the e-i-c for the element that has the attribute with the value I'm trying to modify - but I still have no success.


    I now get no value at all when I output the text string later in the page. So I guess I'm still doing something wrong. I suspect I'm just not getting the value of the attribute into the function properly to begin with. Is there a way to check the function at the command line like you suggested in the previous one?

    1-Visitor
    October 1, 2013
    KIm,

    you can test the function in the same way as before;
    source the file
    source zero.acl
    then place your cursor in the element to be processed and on the Arbortext command line type the following and press enter...
    eval stripzero($w, oid_current_tag())

    If that doesn't return a value, then the problem is in the function itself.
    If this returns the correct value then..
    - on the eic for the element, add a usetext (placement = after) that outputs the savetext together with a text string, eg
    <usetext source="\" **=" \,num.txt&quot;=" placemnt="after"></usetext>

    You should see '**' followed by the number output at the end of the element.
    If it is then the problem is with the output of the save text later in the document, if not then it's a problem with the attribute rule or savetext.


    Adrian Jordin - Senior Consultant
    Mekon Ltd.
    intelligent content solutions
    e adrian.jordin@mekon.com<|">mailto:adrian.jordin@mekon.com>| t +44 (0)117 303 5202 | m +44 (0)7515294338| w www.aerospace-defence.com<">http://www.aerospace-defence.com>

    Todays content needs agility - www.congility.com
    1-Visitor
    October 1, 2013
    Try fillvaling into a usetext source to see what the system-func is returning.

    Suzanne


    kmccain1-VisitorAuthor
    1-Visitor
    October 3, 2013

    Thank you for your help again. I'm getting closer at least. I confirmed that the function is doing its thing correctly by opening my test file and sourcing the script (zero.acl - below) and using the eval command. It pops up a box with the truncated number. So that's good.


    function stripfigno(wid, oid) {
    local x, i, val
    $x = oid_attr(oid, 'figureNumber')
    $i = match($x, '[^0]')
    $val = substr($x, $i)
    return $val
    }


    There is a problem with the savetext, though, because when I put a usetext in the element with the attribute rule as you suggested all I get for output is the random text - ** and then nothing. My attribute rule is:


    <att>
    <fillval attname="stripfigno" attloc="system-func" fillcat="savetext" fillchar="conrule">
    <charsubset><savetext conrule="ipdfigno.txt"></charsubset>
    </att>


    When I open my file that I am using to test I am also getting this warning:


    "Att match: no user defined function named "stripfigno". This is a FOSI coding or application ACL error."


    As I said in the beginning, I'm not very familar with ACL so is there something else I need to do in the fosi so it knows how/where to find the function?


    Right now, I have the script in my custom\scripts directory as you suggested, but ultimately I would like to be able to put multiple functions into an instance.acl file and keep it in the central custom folder with the dtd and fosi rather than copy scripts to all the writers C: drives. So that's where I'm trying to head.

    October 3, 2013
    Just a quick glance, I think your conrule for your savetext should be the return of stripfigno. Ipdfigno.txt looks to be the savetext id?
    October 3, 2013
    As for the FOSI warning, did you put the ACL file with this code in the custom\init so it loads on startup? The function must be loaded and available prior to the FOSI loading, so putting this in scripts or editinit may not load the function in time.
    1-Visitor
    October 3, 2013
    Kim,

    the problem is the second part of the attribute rule. You put the savetext name in the construction field.
    Try the following...

    <att>
    <fillval attname="stripfigno" attloc="system-func" fillcat="savetext"&lt;br"/>fillchar="conrule">
    <charsubset>
    <savetext textid="ipdfigno.txt"></charsubset>
    </att>


    Adrian Jordin - Senior Consultant
    Mekon Ltd.
    intelligent content solutions
    e adrian.jordin@mekon.com<|">mailto:adrian.jordin@mekon.com>| t +44 (0)117 303 5202 | m +44 (0)7515294338| w www.aerospace-defence.com<">http://www.aerospace-defence.com>

    Todays content needs agility - www.congility.com
    1-Visitor
    October 3, 2013
    Kim,

    The error message means the function had not been sourced when formatting began. For testing purposes, you can use the ACL source command at the command line to read in the file with the ACL function, or you can copy the function and paste it in the command line. You also need to set the savetext textid characteristic in the att.Then re-compile the FOSI and format the document. The error message should go away and the output should be as desired. If not, fillval the return value from the function into a usetext source instead of a savetext conrule so it is immediately output. You can debug from there.

    The source command is documented in Help info, which also discusses startup files for production purposes.

    Suzanne


    kmccain1-VisitorAuthor
    1-Visitor
    October 8, 2013

    First of all I want to thank everyone for their help and patience. I've just had a chance to fiddle with this again today and I found that if I put the acl script in the custom\editinit directory on my C: drive, it works when I call the function in the fosi. (after fixing the savetext rule!).


    It does not work if it is in either the \custom\scripts or custom\init directories, although from what I read in the documentation, it looks like editor should search the init directory before editinit ??


    I don't want to have to copy it to all the writers' PCs, so I created a documenttype.acl file in the dtd directory (which is in a network location) and put this function in it and it seems to work from there, although I cannot get it to work if I try to use an instance.acl file instead.. I have to admit, I'm not really sure what the difference is.. or which is better to use. But it's working! Thank you all so much! Now I'm hoping I can write some functions on my own to fix a few other things.