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

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

looking for feedback

ptc-1908075
1-Newbie

looking for feedback

I dreamed up some fancy FOSI footwork awhile back that seemed like it might be useful, but I have never had occasion to use it in a production FOSI. I am wondering if it is worth including in my book. It is detailed below. Whaddya think?


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


In the example below,the fancy FOSI footwork is not required --plain vanilla FOSI coding works fine, and the fancy footwork code is half again as long as the vanilla code. However, maybe the fancy FOSI footwork could be useful in certain complex situations that would be easier with a "case" approach.

The fancy footwork code uses different increment values with the enumerat category to create unique bitmap index numbers that represent the presence of required and optional elements. The example is in SGML so the ampersand (&) connector can be utilized. The ampersand connector means all of the elements in the content model must occur, but they may occur in any order.In this particular DTD, three of the five elements are optional, and there are eight possible bitmap index numbers.Note that this stunt does not work when an element is repeatable, unless it is limited to nine iterations.

In the SGML file, the first and subsequent odd lines show the elements authored in the output order, while the second and subsequent even lines show the elements in random order. Either way, the output is the same. PDF is attached.

The FOSI tests for each bitmap index number and applies the appropriate formatting.

SGML DTD fragment



SGML fragment
<name><first>Yvette</first><last>Bonne</last></name>
<name><last>Bonne</last><first>Yvette</first></name>

<name><first>Jonathan</first><last>Green</last><suffix>Jr.</suffix></name>

<name><suffix>Jr.</suffix><last>Green</last><first>Jonathan</first></name>
<name><first>Blanche</first><middle>Anne</middle><last>White</last></name>
<name><middle>Anne</middle><last>White</last><first>Blanche</first></name>
<name><first>John</first><middle>James</middle><last>Boddy</last><suffix>III</suffix></name>
<name><suffix>III</suffix><middle>James</middle><last>Boddy</last><first>John</first></name>
<name><honorific>Miss</honorific><first>Josephine</first><last>Scarlet</last></name>
<name><last>Scarlet</last><honorific>Miss</honorific><first>Josephine</first></name>
<name><honorific>Prof.</honorific><first>Peter</first><last>Plum</last><suffix>Sr.</suffix></name>
<name><suffix>Sr.</suffix><honorific>Prof.</honorific><last>Plum</last><first>Peter</first></name>
<name><honorific>Mrs.</honorific><first>Patricia</first><middle>Ann</middle><last>Peacock</last></name>
<name><last>Peacock</last><first>Patricia</first><honorific>Mrs.</honorific><middle>Ann</middle></name>
<name><honorific>Col.</honorific><first>Michael</first><middle>Algernon</middle><last>Mustard</last><suffix>IV</suffix></name>
<name><last>Mustard</last><suffix>IV</suffix><middle>Algernon</middle><first>Michael</first><honorific>Col.</honorific></name>

FOSI fragment - Regular coding
<stringdecl textid="first.txt" literal="">
<stringdecl textid="greeting.txt" literal="">
<stringdecl textid="honorific.txt" literal="">
<stringdecl textid="last.txt" literal="">
<stringdecl textid="middle.txt" literal="">
<stringdecl textid="name.txt" literal="">
<stringdecl textid="suffix.txt" literal="">
...
<e-i-c gi="first" context="name">
<charlist inherit="1" charsubsetref="SUPPRESS">
<savetext textid="first.txt" conrule="#CONTENT,\" \&quot;=">
</charlist>
</e-i-c>
<e-i-c gi="honorific" context="name">
<charlist inherit="1" charsubsetref="SUPPRESS">
<savetext textid="honorific.txt" conrule="#CONTENT,\" \&quot;=">
</charlist>
</e-i-c>
<e-i-c gi="last" context="name">
<charlist inherit="1" charsubsetref="SUPPRESS">
<savetext textid="last.txt" conrule="#CONTENT">
</charlist>
</e-i-c>
<e-i-c gi="middle" context="name">
<charlist inherit="1" charsubsetref="SUPPRESS">
<savetext textid="middle.txt" conrule="#CONTENT,\" \&quot;=">
</charlist>
</e-i-c>
<e-i-c gi="suffix" context="name">
<charlist inherit="1" charsubsetref="SUPPRESS">
<savetext textid="suffix.txt" conrule="\" \,#content&quot;=">
</charlist>
</e-i-c>
<e-i-c gi="name">
<charlist inherit="1" charsubsetref="block">
<reset resetlist="name.txt" greeting.txt&quot;=">
<reset resetlist="honorific.txt" first.txt=" middle.txt=" last.txt=" suffix.txt&quot;=">
<usetext source="&lt;name.psu">,</name.psu>" placemnt="after"></usetext>
</charlist>
</e-i-c>
<e-i-c gi="name.psu">
<charlist inherit="1"></charlist>
<att>
<specval attname="honorific.txt" attloc="#FOSI" attval="#ANY">
<charsubset>
<savetext textid="greeting.txt" conrule="\Dear" \,honorific.txt,last.txt,\:\&quot;=">
</charsubset>
</att>
<att>
<specval attname="honorific.txt" attloc="#FOSI" attval="#NONE">
<charsubset>
<savetext textid="greeting.txt" conrule="\Dear" \,first.txt,last.txt,\:\&quot;=">
</charsubset>
</att>
<att>
<charsubset>
<usetext source="honorific.txt,first.txt,middle.txt,last.txt,suffix.txt" placemnt="after">
<subchars charsubsetref="block"></subchars>
</usetext>
<usetext source="greeting.txt">
<subchars charsubsetref="block"></subchars>
</usetext>
</e-i-c>

FOSI fragment - Fancy FOSI footwork
<counter initial="0" enumid="flagct">
<stringdecl textid="first.txt" literal="">
<stringdecl textid="greeting.txt" literal="">
<stringdecl textid="honorific.txt" literal="">
<stringdecl textid="last.txt" literal="">
<stringdecl textid="middle.txt" literal="">
<stringdecl textid="name.txt" literal="">
<stringdecl textid="suffix.txt" literal="">
...
<e-i-c gi="first" context="name">
<charlist inherit="1" charsubsetref="SUPPRESS">
<enumerat increm="1000" enumid="flagct">
<savetext textid="first.txt" conrule="#CONTENT">
</charlist>
</e-i-c>
<e-i-c gi="honorific" context="name">
<charlist inherit="1" charsubsetref="SUPPRESS">
<enumerat increm="10000" enumid="flagct">
<savetext textid="honorific.txt" conrule="#CONTENT">
</charlist>
</e-i-c>
<e-i-c gi="last" context="name">
<charlist inherit="1" charsubsetref="SUPPRESS">
<enumerat increm="10" enumid="flagct">
<savetext textid="last.txt" conrule="#CONTENT">
</charlist>
</e-i-c>
<e-i-c gi="middle" context="name">
<charlist inherit="1" charsubsetref="SUPPRESS">
<enumerat increm="100" enumid="flagct">
<savetext textid="middle.txt" conrule="#CONTENT">
</charlist>
</e-i-c>
<e-i-c gi="suffix" context="name">
<charlist inherit="1" charsubsetref="SUPPRESS">
<enumerat increm="1" enumid="flagct">
<savetext textid="suffix.txt" conrule="#CONTENT">
</charlist>
</e-i-c>
<e-i-c gi="name">
<charlist inherit="1" charsubsetref="block">
<reset resetlist="flagct" name.txt=" greeting.txt&quot;=">
<reset resetlist="honorific.txt" first.txt=" middle.txt=" last.txt=" suffix.txt&quot;=">
<usetext source="&lt;name.psu">,</name.psu>" placemnt="after"></usetext>
</charlist>
</e-i-c>
<e-i-c gi="name.psu">
<charlist inherit="1"></charlist>
<att>
<specval attname="flagct" attloc="#FOSI" attval="#EQ#1010">
<charsubset>
<savetext textid="name.txt" conrule="first.txt,\" \,last.txt&quot;=">
<savetext textid="greeting.txt" conrule="\Dear" \,first.txt,\=" \,last.txt,\:\&quot;="></charsubset>
</att>
<att>
<specval attname="flagct" attloc="#FOSI" attval="#EQ#1011">
<charsubset>
<savetext textid="name.txt" conrule="first.txt,\" \,last.txt,\=" \,suffix.txt&quot;=">
<savetext textid="greeting.txt" conrule="\Dear" \,first.txt,\=" \,last.txt,\:\&quot;="></charsubset>
</att>
<att>
<specval attname="flagct" attloc="#FOSI" attval="#EQ#1110">
<charsubset>
<savetext textid="name.txt" conrule="first.txt,\" \,middle.txt,\=" \,last.txt&quot;=">
<savetext textid="greeting.txt" conrule="\Dear" \,first.txt,\=" \,last.txt,\:\&quot;="></charsubset>
</att>
<att>
<specval attname="flagct" attloc="#FOSI" attval="#EQ#1111">
<charsubset>
<savetext textid="name.txt" conrule="first.txt,\" \,middle.txt,\=" \,last.txt,\=" \,suffix.txt&quot;=">
<savetext textid="greeting.txt" conrule="\Dear" \,first.txt,\=" \,last.txt,\:\&quot;="></charsubset>
</att>
<att>
<specval attname="flagct" attloc="#FOSI" attval="#EQ#11010">
<charsubset>
<savetext textid="name.txt" conrule="honorific.txt,\" \,first.txt,\=" \,last.txt&quot;=">
<savetext textid="greeting.txt" conrule="\Dear" \,honorific.txt,\=" \,last.txt,\:\&quot;="></charsubset>
</att>
<att>
<specval attname="flagct" attloc="#FOSI" attval="#EQ#11011">
<charsubset>
<savetext textid="name.txt" conrule="honorific.txt,\" \,first.txt,\=" \,last.txt,\=" \,suffix.txt&quot;=">
<savetext textid="greeting.txt" conrule="\Dear" \,honorific.txt,\=" \,last.txt,\:\&quot;="></charsubset>
</att>
<att>
<specval attname="flagct" attloc="#FOSI" attval="#EQ#11110">
<charsubset>
<savetext textid="name.txt" conrule="honorific.txt,\" \,first.txt,\=" \,middle.txt,\=" \,last.txt&quot;=">
<savetext textid="greeting.txt" conrule="\Dear" \,honorific.txt,\=" \,last.txt,\:\&quot;="></charsubset>
</att>
<att>
<specval attname="flagct" attloc="#FOSI" attval="#EQ#11111">
<charsubset>
<savetext textid="name.txt" conrule="honorific.txt,\" \,first.txt,\=" \,middle.txt,\=" \,last.txt,\=" \,suffix.txt&quot;=">
<savetext textid="greeting.txt" conrule="\Dear" \,honorific.txt,\=" \,last.txt,\:\&quot;="></charsubset>
</att>
<att>
<charsubset>
<usetext source="name.txt">
<subchars charsubsetref="block"></subchars>
</usetext>
<usetext source="greeting.txt">
<subchars charsubsetref="block"></subchars>
</usetext>
</charsubset>
</att>
</e-i-c>
8 REPLIES 8

I like this technique. I have implemented something similar but nowhere
near as clear/powerful/sustainable, I think where I have an known number of
possible values that can each be present or not present. Including the
values or not is not hard but managing interceding newlines is not
straightforward. I test all previous values to determine whether I need a
linebreak or not as I add the nth value. It works fine but I think it
requires reading a lot more code and muttering under your breath (if a, if
a or b, if a or b or c ....) as you pass through the attribute tests.

I have other cases that I can't even keep it in my head to think about
where I know I have wished for case or if/then/else capabilities. I can
imagine, in the abstract, this FOSI bitmapping strategy simplifying the
maintenance of the code (even if it increases the line count). I care much
more about readability / maintainability than line count.

I say include it.

If I ever implement it, I'll post some code back to the list.

P.S. Did you literally dream it up? I did that once with a FOSI problem.
Six or seven months after we decided a particular feature was not
sustainably implementable, I dreamt a simpler solution than I had managed
to think up before ... we eventually did implement the dream solution.



On Mon, Feb 3, 2014 at 5:02 PM, Suzanne Napoleon <
SuzanneNapoleon@fosiexpert.com> wrote:

> I dreamed up some fancy FOSI footwork awhile back that seemed like it
> might be useful, but I have never had occasion to use it in a production
> FOSI. I am wondering if it is worth including in my book. It is detailed
> below. Whaddya think?
>
> Thanks!
> Suzanne Napoleon
> www.FOSIexpert.com
>
> In the example below, the fancy FOSI footwork is not required -- plain
> vanilla FOSI coding works fine, and the fancy footwork code is half again
> as long as the vanilla code. However, maybe the fancy FOSI footwork could
> be useful in certain complex situations that would be easier with a "case"
>...































































































































































































































I also think you should include it, Suzanne.
Paul, I also have gone to bed at night with a complicated FOSI problem on my mind (talk about having no life) and awakened in the middle of the night with a solution, which proved to actually work when I tried it the next day. This has happened to me more than once. Attribute rules seem to cause the most insomnia.

Thanks, Paul! It would be great if you were able to post some real-world code.


Another way to use a bitmap is to append digits to a string and test the string, which I fooled around with awhile back. Unfortunately, I don't recall the details and that FOSI is not on this laptop, so I'll have to look for it in order to see if it is worth writing up.


I don't recall ever dreaming a solution, but back when FOSI was bleeding edge, I sometimes had dreams in which I was trying to code a FOSI. I woke up when it didn't work and then tried to tell myself that the software runs on a Unix box, not a bed, but the dreams continued for awhile. I had one dream in which I couldn't speak unless I coded it in a usetext.



Suzanne, you're way too far gone: "I had one dream in which I couldn't speak unless I coded it in a usetext."

<usetext source="\I" know.=" right?\&quot;=" placemnt="before"></usetext>


It was a long time ago and it only happened once, but it was truly weird.



>----------
>>

Unable to speak without a usetext? Now that's seriously neurotic!
Top Tags