This is such an obvious topic I was surprised by the lack of information in the Styler manual, help files and on-line. It seems like a really obvious topic to me, but I could only find a single reference to counting the sheets and/or graphics of a figure in the Arbortext help file documentation. "Counting Sheets of a Figure in Styler" which is basically a FOSI topic, and "Coding FOSI support for sheet count".
Is there an equivalent topic showing how counting sheets and/or graphics can be done within Styler itself?
Ideally, the styling should be able to recognize when there are multiple graphics/sheets in a figure and output the Figure number, title, followed by (Sheet 1 of n), thus if there are multiple sheets/graphics in a figure it should output something like "Figure 1. Name of Figure (Sheet 1 of 5)".
Solved! Go to Solution.
I also posted at Adepter's, and Clay Helberg replied with a very useful text.
"Hi Greg—
I don’t have time to test this now, but I would think you could do something like this using an XPath condition, along these lines:
Sheet/Title->
If (count(ancestor::figure/sheet)>1):
Gentext After: (Sheet {xpath-string(count(preceding-sibling::sheet)+1)} of {xpath-string(count(ancestor::figure/sheet))})
I hope you can interpret my pseudo-Styler code here.
--Clay"
I took this example and this is how I worked with it in Styler, my reply to Clay:
Hi Clay,
Ok! Using your coding I managed to implement it within Styler. It has to be divided though.
What I did was select the element graphic everywhere and I inserted a condition, chose type If, and clicked on the New Xpath Test… button. I entered:
(count(ancestor::figure/graphic)>1)
Then with the condition selected I chose the Category: Generated text and clicked on the Edit Button next to Add before element content: At this point it gets a bit funny to edit, because you cannot simply paste in text, there are additional steps;
Type “Sheet ” then from the Insert menu choose Xpath String… at that point when the dialog box comes up you can insert the xpath string in the XPath Expression: field
count(preceding-sibling::graphic)+1
I then clicked on ok, typed “ of “ and repeated the process for the following:
count(ancestor::figure/graphic)
Note - I found I can edit the xpath string by selecting it and choosing modify attributes from the right click context menu
After editing this is complete, choose from the File menu Apply and Close.
I copied the code from the Add before element content: field so you can see it:
Sheet•<_gte:XPathString expr="count(preceding-sibling::graphic)+1"/>•of•<_gte:XPathString expr="count(ancestor::figure/graphic)"/>
And, it works! Woot! Now only the figures with multiple graphics show "Sheet 1 of 7" for example.
Many thanks for your help Clay!
Greg
🙂
I’ve been digging I came across a couple of articles at support.ptc.com, TPI 140544 and CS185369 which are almost related to this topic.
I borrowed some of the code there and modified it into the following which in Styler I placed into the Add before element content: field of graphic everywhere:
count(preceding-sibling::graphic)+1
and
count(ancestor::figure/graphic)
Note these are added within the Add before element content: field by using the edit button, you have to insert xpath strings and the resulting code when copied from the finished field is this:
Sheet•<_gte:XPathString expr="count(preceding-sibling::graphic)+1"/>•of•<_gte:XPathString expr="count(ancestor::figure/graphic)"/>
I get “Sheet 1 of 7” for this and “Sheet 1 of 1” which I don’t really want but hey, any progress is progress!
I also posted at Adepter's, and Clay Helberg replied with a very useful text.
"Hi Greg—
I don’t have time to test this now, but I would think you could do something like this using an XPath condition, along these lines:
Sheet/Title->
If (count(ancestor::figure/sheet)>1):
Gentext After: (Sheet {xpath-string(count(preceding-sibling::sheet)+1)} of {xpath-string(count(ancestor::figure/sheet))})
I hope you can interpret my pseudo-Styler code here.
--Clay"
I took this example and this is how I worked with it in Styler, my reply to Clay:
Hi Clay,
Ok! Using your coding I managed to implement it within Styler. It has to be divided though.
What I did was select the element graphic everywhere and I inserted a condition, chose type If, and clicked on the New Xpath Test… button. I entered:
(count(ancestor::figure/graphic)>1)
Then with the condition selected I chose the Category: Generated text and clicked on the Edit Button next to Add before element content: At this point it gets a bit funny to edit, because you cannot simply paste in text, there are additional steps;
Type “Sheet ” then from the Insert menu choose Xpath String… at that point when the dialog box comes up you can insert the xpath string in the XPath Expression: field
count(preceding-sibling::graphic)+1
I then clicked on ok, typed “ of “ and repeated the process for the following:
count(ancestor::figure/graphic)
Note - I found I can edit the xpath string by selecting it and choosing modify attributes from the right click context menu
After editing this is complete, choose from the File menu Apply and Close.
I copied the code from the Add before element content: field so you can see it:
Sheet•<_gte:XPathString expr="count(preceding-sibling::graphic)+1"/>•of•<_gte:XPathString expr="count(ancestor::figure/graphic)"/>
And, it works! Woot! Now only the figures with multiple graphics show "Sheet 1 of 7" for example.
Many thanks for your help Clay!
Greg
🙂