Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X
Hi all,
I am a beginner, a bit overwhelmed with creating my first stylesheet. I know I will have to use FOSI eventually but I am trying to get as much done in Styler first. I was wondering if there is an XPath override to capture the previous element's generated text title number in Styler? I was only able to retreive the title without the number.My element title numbers are restarting at 1 and I would like them to +1 from the previous element's number.
Also, can one output the title number after the element content in Styler, or will I have to do a FOSI edit with a text variable?
I'm using 5.3.
Thanks for any help!
Regards, Caroline
Hi Gareth,
Thanks for your reply. I have tried using divisions and formal blocks, but these are sibling elements and keep restarting their numbering at 1. That is why I was trying to capture the generated label number from the previous sibling element.
Hi Brandon,
Thanks for your reply. Going by the PDF I was given of finished output which is my only reference, Foreword Title is labeled 10, List of Related Publications Title is labeled 8 and Acronyms Title is labeled 9. Then Purpose Title is labeled 1, Scope is 2 and Manual Structure is 3.
If I make <forewordwp> a Division and <foreword> a Formal Block, Foreword Title is labeled 4. If I make <foreword> a Division, it restarts at 1. No matter how I've set up the rest of the elements, as either Formal Blocks or Divisions, the title numbers are always 1 for everything below Foreword. So I thought there might be an XPath override for the current level I could enter in the Title Number dialog box that would grab the label # for Purpose which I could +1 to get 2 for the Scope Title, and 3 for Manual Structure and so on. I tried using the restart numbering option but was unsuccessful.
Thanks for any help!
Caroline
-----------------------------------------------------------------------------------------
<forewordwp>
<foreword>
<para0>
<title>FOREWORD</title>
</para0>
<lrp>
<title>LIST OF RELATED PUBLICATIONS</title>
</lrp>
<abbrsect>
<title>ACRONYMS AND ABBREVIATIONS</title>
<para></para>
<acronymlist>
<term></term>
<def></def>
</acronymlist>
</abbrsect>
</foreword>
<purpose>
<title>PURPOSE</title>
</purpose>
<scope>
<title>SCOPE</title>
</scope>
<manstru>
<title>MANUAL STRUCTURE</title>
</manstru>
</forewordwp>
Thank you again, Brandon. I tried both expressions in the override box:
count(preceding-sibling::purpose | preceding-sibling::scope | preceding-sibling::manstru) + 1
count(preceding-sibling::*[self::purpose | self::scope | self::manstru]) + 1
but I'm still getting a 1 for the label numbers. Unless I misunderstood? Plus there are more sibling elements than these three so the expression would be unwieldy. I'm spending too much time on this, I might just hard-code the numbers as a last resort. I really appreciate all your help.
Hi Brandon,
Again, thank you so much!
This kinda works:
count(../preceding-sibling::*[title])
I just have to tweak it for when there are other elements with titles between siblings.
Hi Steve,
Yes, there is an index with a title between two siblings, which threw off the numbering. So I adjusted the xpath expression to
count(../preceding-sibling::*[title]) - 1
for the elements after the index.
And then for the first three elements which are numbered 10, 8 and 9 respectively in my PDF reference, I'm hoping I can cut and paste them to match their position in the PDF.)
Hi Steve,
Thank you so much! But I am getting the same issue -- coverage is labeled 4 and locinfo is labeled 6. <indexscheme> is not showing up in my PDF so I don't know what it is or what I'm supposed to do with it. It has no content. Maybe I can delete it?
<coverage>
<title></title>
<para></para>
</coverage>
<indexscheme>
<title></title>
</indexscheme>
<locinfo>
<title></title>
<para></para>
</locinfo>
Hi Brandon,
Thank you, that resolved it! I have zero experience with XPath and the lightbulb didn't go on regarding index/indexscheme until I had looked at the two XPATH expressions side by side.Your explanation was helpful. The XPATH syntax just wasn't clicking for me.
I am so grateful for everyone's help!