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

Styler 5.3 M020: Inserting XPath String in Header

JRKetelsen
1-Newbie

Styler 5.3 M020: Inserting XPath String in Header

Hello, again.



I seem to have uncovered a potential issue with Styler.



I have a document that has a section1 element. The section1 element has
a title. Each section1 element triggers a pagebreak. I want to include
the section1 title in the header of the document.



I have edited my pageset headers to insert an Xpath string. The Xpath
string is "//section1[.]/title" . The behavior of Styler is to place
the 1st occurrence of section1/title in the header, and it never changes
for the entire document. I have tested the Xpath string using an XML
IDE and the behavior is as I expect.



This has to be a common thing. Am I missing something? If I was using a
FOSI I could set a savetext and usetext.



Thanks for any help.



JR



12 REPLIES 12

On 9/5/07, Ketelsen, JR <jr.ketelsen@flatironssolutions.com> wrote:
>
> Hello, again.
>
> I seem to have uncovered a potential issue with Styler.
>
> I have a document that has a section1 element. The section1 element has a
> title. Each section1 element triggers a pagebreak. I want to include the
> section1 title in the header of the document.
>
> I have edited my pageset headers to insert an Xpath string. The Xpath
> string is "//section1[.]/title" . The behavior of Styler is to place the 1
> st occurrence of section1/title in the header, and it never changes for
> the entire document. I have tested the Xpath string using an XML IDE and
> the behavior is as I expect.
>
> This has to be a common thing. Am I missing something? If I was using a
> FOSI I could set a savetext and usetext.
>

Hi JR,

I too am a recovering FOSIholic (ok, not that recovering, I have most of my
work still in FOSI) but I am trying to learn the Styler view of the world.
There is an awful lot that Styler does that is probably *easier* for someone
who knows nothing about FOSI. And there is also a lot that can be improved
from a usability standpoint.

In this instance, it may be a little of both.

First, section must be a division. It is, isn't it? If not, seriously
consider re-styling it as a division (rather than block or formal block or
something else). This will give you many "free" benefits (notably PDF
bookmarks, distinct html pages in web or html help output) in addition to
making it available in the headers and footers.

Now that you have defined section as a division:
Select Format Page Sets.
Highlight the desired page set.
Click Edit.
Click the Headers tab.
Click Edit Header.
Place your cursor in the desired informaltable cell.
Select Insert > Division Reference.
Highlight the appropriate division (section1).
Choose first or last division started on the page.
Choose the desired cross reference format (text).

Click OK/OK/YeahSure/Close/etc./etc. until you have carpal tunnel and now
you should be good to go! (Ooops, don't forget to save!)

If there is some reason you can't make section1 a division, post back here
and there maybe other, lest Styler-ish ways to get where you need to go.


(Ok, ok, there is also a lot that Styler does very well in intuitive ways!
No, really, I'm not just making nice with our friends at PTC. I'm really
not.)

--
Paul Nagai

Hi JR--

I'm not a Styler user, but I think the problem lies in your XPath expression. The way your expression is written, I would expect the exact behavior you are describing, i.e. it always uses the first section title independent of context. (That's what the starting "//" does, it says "evaluate the rest of the expression independent of context".)

I think the expression you want is probably closer to ".//section1/title". By putting a dot in front, you're asking for any descendants of the current context node that are titles as children of section1 elements.

Hope that helps.

--Clay

Paul;



Thanks for your advice.



I actually tried the division ref approach before I posted.



I must be missing something. Section is a division, but inserting the
division reference has no effect on the printed output. The division
ref simply does not appear in the header. Regardless of how I set the
values (first on page, last, etc.) title is styled as title. TOC works
as expected.



I will keep plugging away on this.





JR


Clay;



Thanks for your advice. The XPath expression that I am attempting to
use works as expected when I test it using oXygen 8.2.



I still think there is a problem with Arbortext not resolving this
expression.



JR


Hi JR--

I think there's something missing here. I don't know what oXygen is doing, but the spec is quite clear that an XPath expression that starts with "//" is supposed to be evaluated independent of the context. Your description of Arbortext's interpretation of the expression is the correct one. See the XPath specification for clarification on this point (

On 9/7/07, Ketelsen, JR <jr.ketelsen@flatironssolutions.com> wrote:
>
> Paul;
>
> Thanks for your advice.
>
> I actually tried the division ref approach before I posted.
>
> I must be missing something. Section is a division, but inserting the
> division reference has no effect on the printed output. The division ref
> simply does not appear in the header. Regardless of how I set the values
> (first on page, last, etc.) title is styled as title. TOC works as
> expected.
>
I know that you can disrupt the underlying code of a division element by
editing FOSI source. Have you done that for section or section1? Or, more
likely, the title element? Editing FOSI source for title severs the Styler
interface connection with that code. Changes made to title (or any of its
conditions or contexts *after* editing FOSI source will *not* be made to the
actual code although the Styler user interface may display the change.

I don't know if that's English or not. Hopefully it's clear enough.

One quick way to see if the code is present is to edit the .style file with
a text editor and search for the following:
xrefidtag="section"
OR
xrefidtag="section1"

You should see a block of about five savetexts with textids of:
Label_Number.xref
Number.xref
Text.xref
etc.

If you can't find these AND you have edited FOSI source for title, the cross
reference formats they represent (those pulled in the Division reference
dialog) won't work since under the covers, these variables are being called
(but, obviously, not set). If you haven't edited FOSI source for title, that
code may not be present in your .style file and is, instead, assumed by
Styler's core code. (I haven't quite figured this bit out yet ... some
things are only expressed in the .style file if you "go off-road.")

UNRELATED GUESS:
Do you have section/section1 set as a division in your .dcf? I don't see
anything anywhere in Styler help indicating this is required for the
functionality you're trying to develop, but maybe it is indeed required.

JUST FOR FUN:
Here is an attribute test containing the xref savetexts for chapter from my
stylersheet. This is *not* a standard bit of code. I, unfortunately, have
severed the relationship between the title element's styler ui and the
underlying code, but it illustrates where/how you can "fix" this if you,
too, have "broken" it:
<att>
<charsubset>
<savetext textid="cnt__chapter.txt" conrule="cnt__chapter:gps_doc.cnt[AR]"/">
<savetext textid="num__chapter.txt" conrule="cnt__chapter.txt"/">
<savetext textid="label__chapter.txt" conrule="!Chapter&lt;br"/>!,num__chapter.txt,!!"/>
<savetext textid="beforetext" conrule="!&lt;_sfe:BeforeOrAfterText&lt;br /&gt;xmlns:_sfe="&lt;br /&gt;&lt;a style="COLOR: blue; TEXT-DECORATION: underline" target="_BLANK" href="http://www.arbortext.com/namespace/Styler/StylerFormattingElements"&gt;http://www.arbortext.com/namespace/Styler/StylerFormattingElements"&lt;/a&gt;&lt;br /&gt;xmlns:_ufe="&lt;a style="COLOR: blue; TEXT-DECORATION: underline" target="_BLANK" href="http://www.arbortext.com/namespace/Styler/UserFormattingElements"&gt;!,@0pt,!&lt;_font"&gt;http://www.arbortext.com/namespace/Styler/UserFormattingElements"&gt;!,@0pt,!&lt;_font&lt;/a&gt;&lt;br /&gt;xmlns:_gte="&lt;a style="COLOR: blue; TEXT-DECORATION: underline" target="_BLANK" href="http://www.arbortext.com/namespace/Styler/GeneratedTextElements"&gt;!,label__chapter.txt,!&lt;/_font&gt;!,\"&gt;http://www.arbortext.com/namespace/Styler/GeneratedTextElements"&gt;!,label__chapter.txt,!&lt;/_font&gt;!,\&lt;/a&gt;&lt;br /&gt;\,!&lt;/_sfe:BeforeOrAfterText&gt;!" placemnt="before"/">
<savetext textid="repeat_title.txt" conrule="\\"/">
<savetext textid="repeat_title_bottom.txt" conrule="\\"/">
<savetext textid="Label_Number.xref" conrule="label__chapter.txt"&lt;br"/>xrefidtag="chapter"/>
<savetext textid="Label_Number_Text.xref" conrule="label__chapter.txt,!&lt;br /&gt;&lt;_sfe:CrossReferenceTitle xmlns:_sfe="&lt;br /&gt;&lt;a style="COLOR: blue; TEXT-DECORATION: underline" target="_BLANK" href="http://www.arbortext.com/namespace/Styler/StylerFormattingElements"&gt;!,#CONTENT,!&lt;/_sfe:CrossReferenceTitle&gt;!" &quot;=">http://www.arbortext.com/namespace/Styler/StylerFormattingElements">!,#CONTENT,!!'
xrefidtag="chapter"/>
<savetext textid="Number.xref" conrule="num__chapter.txt"&lt;br"/>xrefidtag="chapter"/>
<savetext textid="Page.xref" conrule="foliostr[BO]" xrefidtag="chapter"/">
<savetext textid="Text.xref" conrule="!&lt;_sfe:CrossReferenceTitle&lt;br /&gt;xmlns:_sfe="&lt;br /&gt;&lt;a style="COLOR: blue; TEXT-DECORATION: underline" target="_BLANK" href="http://www.arbortext.com/namespace/Styler/StylerFormattingElements"&gt;!,#CONTENT,!&lt;/_sfe:CrossReferenceTitle&gt;!" &quot;=">http://www.arbortext.com/namespace/Styler/StylerFormattingElements">!,#CONTENT,!!'
xrefidtag="chapter"/></charsubset>
</att>

That is in:
<e-i-c gi="title" context="chapter" occur="all">

To get there, select title in the elements list.
Then select Elements/EditElementSource/FOSI.

--
Paul Nagai

Clay;



I did try your expression. It returned nothing in Arbortext. I am
continuing to troubleshoot this issue and will report when I have a
solution.



I am investigating the use of inserting a division reference and that
does not appear to work as expected. I must have something styled
incorrectly.



Thank for you help.



JR


Hi JR--

Hmm. I checked the Styler help file, and found this regarding XPath expressions in generated text:

Relative expressions are evaluated relative to the element being styled, except when you are inserting an XPath expression in the generated text of a header or footer, where the document element is used as the context node. (emphasis mine)

It looks like you aren't going to be able to use XPath to do what you want, since the context for resolving the expression never changes.

I think you'll have to use Styler's Division mechanism for this. I don't use Styler, so I'm afraid I can't help with that, but at least it's clear now why the XPath approach doesn't work....

--Clay

JR,

Well... maybe.

If I follow your original post correctly, whatever element you happen to
be 'in' when the next page is triggered in the pageset (not necessarily
by the 'pagebreak', might be that the previous page is full), you want
the 'title' of the current-or-ancestor 'section1' to be in the header.
Another way to say that is, you want the 'title' of the current element
when the 'section1' triggers a pagebreak, and you want the 'title' of
the parent-or-ancestor 'section1' when another page in the pageset
results from the page having gotten 'full'.

Your XPath includes the predicate '[.]', which might have worked if you
were always in a 'section1' when the page triggered and Styler kept
track of the current node as the context, but you won't be and it
apparently doesn't.

I also don't use Styler, so... Do you know a way to pass the output of
an ACL function into that header? If so, there's a way to use a similar
XPath to get the value you want no matter where you are in the document.

Steve Thompson
(316)977-0515
When the only tool you have is a hammer,
Everything looks like a hard disk...

Clay;



Thanks again for looking at this issue. I am going the division
reference route, as it seems that that is the preferred Styler method.



Thank you again for your time.



JR

Just to clarify, for the record, an XPath predicate of '[.]' doesn't do
anything. Removing it from the expression would not change the result
of the expression at all (or shouldn't, if the XPath implementation is
correct, anyway).

-Brandon 🙂




Thank you to everyone that responded to this question. The way I
finally got this to work was to use division references.



Division reference was not working due to the way that I had title in
section1 styled. I simply added a first title in section1 context, and
that fixed my problem.



JR


Announcements