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

Community Tip - Help us improve the PTC Community by taking this short Community Survey! X

Questions about userulehook and generating external files

JasonBuss
1-Newbie

Questions about userulehook and generating external files

Hi all,

I am upgrading to 5.3 M040 from 5.1F, and have a question regarding the
userulehook and generating external files.

I have a FOSI stylesheet that writes several lines from several e-i-cs
to a variable, and then emits a usetext that has a userule=1 to emit an
external file.

In the past, I had set my userule=1, and called a script using the
userulehook that would take the result and write it to a specific
location with a specific name. I would still get the *.exp file, but I
would just write it out to my TEMP directory. I could never get any
userule other than 1 to write an external file (I tried 3, but never got
a file).

In 5.3 M040, they have changed the default behavior to never call the
hook for userules of 1 or 2, so that bit of code quit working, since it
wouldn't call the function tied to the userulehook called by add_hook().
I changed my userule to 3, and set my userulehook function to test for a
userule of 3, and now I can get my external files again. The issue is
now all the information that was stored in the variable that gets
written to the external file also gets autogenerated at the end of the
document. There is no suppress valid for usetext, so I'm not sure how
to fix this. If the document is big enough, it can write several pages
of info, or even worse, return an error "[A12692] A userulehook function
returned an illegal value (0). The final index will not be generated",
after which Editor often Segment 11's on me.

I wish I could just get my metadata directly from the markup, but some
of what is being written out is TOC information, so I have to have the
ordinal page number for when that e-i-c formats. Has anyone been
working with the userulehooks lately (5.3) or found a method for getting
ordinal page numbers from an e-i-c without the
savetext/usetext-to-external file?

Thanks,

-Jason A. Buss
4 REPLIES 4

Jason,

I don't think userule="1" is no longer supported in 5.3m040.

Userule="1" still works to produce an external file. I don't use any ACL
or anything else and I still get external file. These are snippets from
one of my FOSIs:


<stringdecl textid="lepmatter.tiv" status="1">
<stringdecl textid="lepmatter-ext.tiv" status="1">

<e-i-c gi="doc">
<charlist>
<usetext source="&lt;external-lep">, </external-lep>" placemnt="after">
</usetext>
</charlist>
</e-i-c>

<e-i-c gi="external-lep">
<charlist>
<usetext source="lepmatter-ext.tiv" userule="1">
</usetext>
</charlist>
</e-i-c>

<footer>
<usetext source="do-chg01.tdv[FI]," do-chg01.tdv[to],=" {etc.=" etc.=" ..}=">
<subchars>
<textbrk startln="0" endln="0">
<savetext textid="lepmatter.tiv" conrule="&lt;newline">, volstr.tdv[BO],
pgprefix.tdv[BO], pagect.tdv, tocfill, chglvl.tdv, 1pi, </newline>"
append="1">
<savetext textid="lepmatter-ext.tiv" conrule="&lt;lepentry">, <leppage>,
volstr.tdv[BO], pgprefix.tdv[BO], pagect.tdv, </leppage>, <lepchg>,
chglvl.tdv, </lepchg>, </lepentry>, \ &#RE;\" append="1">
</subchars>
</usetext>
</footer>

This is produced in a file named external-lep.exp:

<lepentry><leppage>Title </leppage><lepchg> 2</lepchg></lepentry>
<lepentry><leppage>A </leppage><lepchg> 2</lepchg></lepentry>
<lepentry><leppage>i </leppage><lepchg> 0</lepchg></lepentry>
<lepentry><leppage>ii </leppage><lepchg> 1</lepchg></lepentry>
<lepentry><leppage>iii </leppage><lepchg> 0</lepchg></lepentry>
<lepentry><leppage>iv </leppage><lepchg> 0</lepchg></lepentry>
<lepentry><leppage>v </leppage><lepchg> 0</lepchg></lepentry>
<lepentry><leppage>vi </leppage><lepchg> 0</lepchg></lepentry>
<lepentry><leppage>vii </leppage><lepchg> 0</lepchg></lepentry>
<lepentry><leppage>viii Blank </leppage><lepchg> 0</lepchg></lepentry>
<lepentry><leppage>1-1 </leppage><lepchg> 2</lepchg></lepentry>
<lepentry><leppage>1-2 </leppage><lepchg> 1</lepchg></lepentry>
<lepentry><leppage>1-3 </leppage><lepchg> 1</lepchg></lepentry>
<lepentry><leppage>1-4 Blank </leppage><lepchg> 0</lepchg></lepentry>
<lepentry><leppage>2-1 </leppage><lepchg> 0</lepchg></lepentry>
<lepentry><leppage>2-2 </leppage><lepchg> 0</lepchg></lepentry>
<lepentry><leppage>3-1 </leppage><lepchg> 0</lepchg></lepentry>
<lepentry><leppage>3-2 </leppage><lepchg> 1</lepchg></lepentry>
<lepentry><leppage>3-3 </leppage><lepchg> 1</lepchg></lepentry>
<lepentry><leppage>3-4 Blank </leppage><lepchg> 0</lepchg></lepentry>
<lepentry><leppage>3-5 </leppage><lepchg> 0</lepchg></lepentry>
<lepentry><leppage>3-6 </leppage><lepchg> 0</lepchg></lepentry>
<lepentry><leppage>3-7 </leppage><lepchg> 0</lepchg></lepentry>
<lepentry><leppage>3-8 Blank </leppage><lepchg> 0</lepchg></lepentry>
<lepentry><leppage>3-9 </leppage><lepchg> 0</lepchg></lepentry>
<lepentry><leppage>3-10 Blank </leppage><lepchg> 0</lepchg></lepentry>

I wish I had a little acl script that would convert the LEOP to "merged"
page numbers as required by TO 00-5-1, but there is not much manual
processing required on the output to get the generated output into
proper shape.

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


Since you are using a userule of 3, I assume that you are also writing
the file yourself, correct? Just because the old behavior of writing the
file for you was only good for userule 1.

Anyway, you should be able to delete all of the markup from the doc that
was passed to your use rule hook before you return and this way the
markup will not be put into your output.

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


On a side note, we ran into some problems with attribute updates in M040
that went away with M060... just thought I'd mention if there wasn't a
specific reason for using M040 on your end.
keith

Is there a method for writing data gathered through the FOSI during
composition other than userule=1? I haven't figured out how to delete
all of that markup from the doc "before I return". The markup being
written out is gathering LOEP and TOC info (pagecount and ordinal page
numbers for TOC subjects), so during the formatting pass, since that
data is being included at the end of the doc, and I can't stop before
the end of the doc, I'm not sure what you mean by deleting the markup
before the return.



Even if the markup is not in the output itself, it gets counted during
the formatting pass, and large documents can create more than one page
of this kind of information, which throws off my pagecount.



I am currently testing a workaround (copy the pgblk.exp from the
$main::dirname of current_doc(doc) just after formatting and before
closing the current doc to open the next). It's not elegant, but
neither was the original solution...



Just out of curiosity, is there a way to send a FOSI variable value OUT
to an ACL function without explicitly writing out to the file system and
post-processing? If I could just get the oid_content and ordinal page
numbers for my TOC subjects out of the FOSI and to my code during
formatting, it would simplify my metadata generation.



Thanks,



-Jason


Top Tags