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

How to in FOSI vs XSLT

ptc-953343
1-Newbie

How to in FOSI vs XSLT

I have a situation where I need to test the preceding siblings and process the contetns accordingly. I know how I would get there with XSLT/XPath but what is the corresponding method in FOSI?

I have a list item in which a para or challenge element can be first and then there can be additional para elements. The Occur first doesn't seem to work in this case. I suppose I have to set some sort of flag when processing the content of an item to indicate the "first thing" has already occurred, is there an alternative to this?

So I have content like this:

<item><challenge>this is challenge</challenge><para>this is a para</para></item>

should format as:

1. this is challenge

this is a para

and

<item><para>this is para 1 </para><para>this is a para</para></item>

should format as:

1. this is para 1

this is a para

If I set the occur to first on <para> I get

1.

this is para 1

this is a para

First is the first occurrence of a para in item, not that it is the first child of item.

Another sort of XSLT question. In XSLT I can use one template to match multiple things, such as match="para | challenge" and then manage the formatting for these similar objects in one template, is there something similar in FOSI? It seems like you have to write and EIC for each of these and then the only way to write code once is to make a text entity out of the content. Are there any other possibilities?

thanks

..dan

9 REPLIES 9

Dan,

No sabe XSLT. I might be misunderstanding. For FOSI:

<e-i-c gi="para"> will match any para that is not more closely identified by context and occurance.

<e-i-c gi="para">
<charlist>
<usetext source="\This" is=" an=" para=" without=" a=" specific=" context=" or=" occurance\&quot;=">
<subchars charsubset="sanserif8.csub">
</subchars>
</usetext>
</charlist>
</e-i-c>

<e-i-c gi="para" context="item" occur="first">
<charlist>
<usetext source="\This" is=" para=" 1\&quot;=">
<subchars charsubset="sanserif8.csub">
</subchars>
</usetext>
</charlist>
</e-i-c>

<e-i-c gi="para" context="item" occur="notfirst">
<charlist>
<usetext source="\This" is=" a=" para\&quot;=">
<subchars charsubset="sanserif8.csub">
</subchars>
</usetext>
</charlist>
</e-i-c>

Every once in a while I use these tow also:
<e-i-c gi="para" context="item" occur="notlast">
<e-i-c gi="para" context="item" occur="last">

If you are talking about formating multiple elements the same way will a styleset work?

<charsubset charsubsetid="sanserif8.csub">

<quadding quad="justify">
<presp minimum="2pt" nominal="10pt" maximum="12pt" priority="med">
<postsp minimum="2pt" nominal="10pt" maximum="12pt" condit="keep" priority="med">
<textbrk startln="1" endln="1">
</charsubset>


\ / Andy Esslinger LM Aero - Tech Order Data
_____-/\-_____ (817) 279-0442 1 Lockheed Blvd, Mail Zone 4285
\_\/_/ (817) 777 3047 Fort Worth, TX 76108


That works if I only have the single content element. I need to set
the counter based upon a challenge being first as well. So when
challenge is frist, the next para is still first so I get 2 items #1's.

..dan

Dan,

You could reset a textid to nothing in the e-i-c for <item>, then set
it to some value at the end (placemnt="after") of a <challenge> or
<para>. An att on <para> could then test the value of the textid to
see if it should set the counter.

It's not quite as straightforward as it would be in XSLT, but, then,
FOSI isn't a particularly declarative language.

-Brandon 🙂


If I understand you correctly, you could code enumerat and usetext on e-i-c gi="item" and then code gi="para" context="item" occur="first" (and "only") and gi="challenge" context="item" with textbrk startln="0" endln"1" (endline charsubset). The lack of startln="1" on the element that isn't first shouldn't matter as long as gi="item" has startln="1".

Tip: e-i-c's are cheap. Use as many of them as you need. If possible, avoid testing stuff, because that is the one thing that can slow the FOSI formatting process.

Good luck!
Suzanne

Whoops! Make that as long as the first element in item has endln="1".
S.


Hi Dan,

To answer your second question first, yes, you can have multiple elements in an e-i-c, such as

<e-i-c gi="title" reserved=" deleted&quot;=" context="subsect">
<charlist> ...

For the situation you describe you might try

<e-i-c gi="challenge" para&quot;=" context="item" occur="first">
<charlist> ...

and

<e-i-c gi="para" context="item" occur="notfirst">
<charlist> ...

As Suzanne mentioned, the enumerate should be on <item>.

This is only a rough outline, I'm sure you can fill in the rest.

Hope this helps.

David

David S. Taylor

Project Manager, Structured Information
Institute for Research in Construction
National Research Council Canada
Bldg. M-23A, Room 239
1200 Montreal Road, Ottawa, ON K1A 0R6

The following works for me. (In a production FOSI, I would probably put the indent in the e-i-cs for para and challenge in a charsubset since it is duplicate code.)

Good luck!
Suzanne

<e-i-c gi="list">
<charlist inherit="1" charsubsetref="block" prespace&quot;=">
<reset resetlist="itemct">
</charlist>
</e-i-c>
<e-i-c gi="item" context="list">
<charlist inherit="1" charsubsetref="block" prespace&quot;=">
<indent inherit="1" leftind="@+1.5pi" firstln="*-1.5pi">
<enumerat increm="1" enumid="itemct">
<usetext source="itemct,\." \,@1.5pi&quot;=" placemnt="before"></usetext>
</charlist>
</e-i-c>
<e-i-c gi="para" context="item" occur="first">
<charlist inherit="1" charsubsetref="endline" prespace&quot;=">
<indent inherit="1" firstln="*">
</charlist>
</e-i-c>
<e-i-c gi="para" context="item" occur="notfirst">
<charlist inherit="1" charsubsetref="block" prespace&quot;=">
<indent inherit="1" firstln="*">
</charlist>
</e-i-c>
<e-i-c gi="challenge" context="item" occur="first">
<charlist inherit="1" charsubsetref="endline" prespace&quot;=">
<indent inherit="1" firstln="*">
</charlist>
</e-i-c>
<e-i-c gi="challenge" context="item" occur="notfirst">
<charlist inherit="1" charsubsetref="block" prespace&quot;=">
<indent inherit="1" firstln="*">
</charlist>
</e-i-c>


Thanks, I realized after seeing your comments last night that I had
the wrong model in mind by trying to control the numbering by the
content. It is something I could easily check for in XSLT, but there
is a way to do it in FOSI a different way.

..dan

Dan,

It sounds like you're getting the hang of it 🙂

In my experience, my guesstimate is that context and occurrence do the trick >90% of the time. #FOSI and SYSTEM-FUNC are needed after that. I recommend using #FOSI and SYSTEM-FUNC only when necessary because: 1) too many of them slow, even cripple, the formatting speed; and 2) With SYSTEM-FUNC, the ACL function adds a configuration issue to the doctype, and IMHO one less configuration issue is always a good thing.

Good luck!
Suzanne


Announcements