cancel
Showing results for 
Search instead for 
Did you mean: 
Security Alert Log4j Security Vulnerability. Click here to know more.
cancel
Showing results for 
Search instead for 
Did you mean: 

Help with XPATH

cleccese
5-Regular Member

Help with XPATH

<index><title></title><tgroup></tgroup>


<sys>
<title></title> <-- The first title in every <sys> does not get included in numbering
<title></title>
<part>
<item><label></label><para></para></item>
<location></location></part>
<part>
<item><label></label><para></para></item>
<location></location></part>
<part>
<item><label></label><para></para></item>
<location></location></part>
<part>
<item><label></label><para></para></item>
<location></location></part>
<part>
<item><label></label><para></para></item>
<location></location></part>
<title></title>
<part>
<item><label></label><para></para></item>
<location></location></part>
<part>
<item><label></label><para></para></item>
<location></location></part>
</sys>


<sys>
<title></title> <-- The first title in <sys> does not get included in numbering
<title></title>
<part>
<item><label></label><para></para></item>
<location></location></part>
<title></title>
<part>
<item><label></label><para></para></item>
<location></location></part>
<part>
<item><label></label><para></para></item>
<location></location></part>
<title></title>

<part>
<item><label></label><para></para></item>
<location></location></part>
<part>
<item><label></label><para></para></item>
<location></location></part>
</sys>


</index>


I want to number the titles in <sys>, excluding the first title. There are multiple <sys> tags and multiple <titles> within <sys>.


I would have thought I could do this myself, but all I'm getting is "0". Thanks!

6 REPLIES 6

If you are in <sys> element context, and wanted to count the number of
title elements excluding the first one. Here is the xpath:

count(title) - 1



On Tue, May 15, 2012 at 4:34 PM, Caroline Leccese <
caroline@thecodesource.net> wrote:

> <index><title></title><tgroup></tgroup>
>
> <sys>
> <title></title> <-- The
> first title in every <sys> does not get included in numbering
> *<title></title>*
> <part>
> <item><label></label><para></para></item>
> <location></location></part>
> <part>
> <item><label></label><para></para></item>
> <location></location></part>
> <part>
> <item><label></label><para></para></item>
> <location></location></part>
> <part>
> <item><label></label><para></para></item>
> <location></location></part>
> <part>
> <item><label></label><para></para></item>
> <location></location></part>
> *<title></title>*
> <part>
> <item><label></label><para></para></item>
> <location></location></part>
> <part>
> <item><label></label><para></para></item>
> <location></location></part>
> </sys>
>
> <sys>
> <title></title> <-- The
> first title in <sys> does not get included in numbering
> *<title></title>*
> <part>
> <item><label></label><para></para></item>
> <location></location></part>
> *<title></title>*
> <part>
> <item><label></label><para></para></item>
> <location></location></part>
> <part>
> <item><label></label><para></para></item>
> <location></location></part>*
> <title></title>*
> <part>
> <item><label></label><para></para></item>
> <location></location></part>
> <part>
> <item><label></label><para></para></item>
> <location></location></part>
> </sys>
>
> </index>
>
> I want to number the titles in <sys>, excluding the first title. There are
> multiple <sys> tags and multiple <titles> within <sys>.
>
> I would have thought I could do this myself, but all I'm getting is "0".
> Thanks!
>
cleccese
5-Regular Member
(To:cleccese)

Thank you, Venkata, but that is still giving me a "0"

I think a little more context would help. This is for numbering in Styler?
If so, are you sure you need to use XPath to get what you want? I suspect
Styler can do it without an XPath expression (even if it will compile it to
an XPath expression for certain outputs, anyway). Where are you trying to
put the XPath in (what element/context, which field/dialog, etc.) and what
XPath expressions have you tried, there?

If it's not for Styler, then what is the context?

Also, just for clarity, can you indicate what the desired result would be
for each case in your example?

-Brandon 🙂


On Tue, May 15, 2012 at 12:34 AM, Caroline Leccese <
caroline@thecodesource.net> wrote:

> <index><title></title><tgroup></tgroup>
>
> <sys>
> <title></title> <-- The
> first title in every <sys> does not get included in numbering
> *<title></title>*
> <part>
> <item><label></label><para></para></item>
> <location></location></part>
> <part>
> <item><label></label><para></para></item>
> <location></location></part>
> <part>
> <item><label></label><para></para></item>
> <location></location></part>
> <part>
> <item><label></label><para></para></item>
> <location></location></part>
> <part>
> <item><label></label><para></para></item>
> <location></location></part>
> *<title></title>*
> <part>
> <item><label></label><para></para></item>
> <location></location></part>
> <part>
> <item><label></label><para></para></item>
> <location></location></part>
> </sys>
>
> <sys>
> <title></title> <-- The
> first title in <sys> does not get included in numbering
> *<title></title>*
> <part>
> <item><label></label><para></para></item>
> <location></location></part>
> *<title></title>*
> <part>
> <item><label></label><para></para></item>
> <location></location></part>
> <part>
> <item><label></label><para></para></item>
> <location></location></part>*
> <title></title>*
> <part>
> <item><label></label><para></para></item>
> <location></location></part>
> <part>
> <item><label></label><para></para></item>
> <location></location></part>
> </sys>
>
> </index>
>
> I want to number the titles in <sys>, excluding the first title. There are
> multiple <sys> tags and multiple <titles> within <sys>.
>
> I would have thought I could do this myself, but all I'm getting is "0".
> Thanks!
>
cleccese
5-Regular Member
(To:cleccese)

Sure Brandon, this is for Styler 5.4. I am not sure I need to use XPATH, it seemed the easiest way to go. I want the titles numbered in <sys>, ignoring the first title, and I want them to restart for each <sys>


I made <sys> a formal block and created two contexts, first title in <sys> and not first title in <sys> and added the gentext title number to not first title. I don't think the logic is correct. Without using XPATH, the titles in the first <sys> are all numbered 1. In the second <sys>, title numbering starts at 2 and increments to 7 so that the third <sys> starts at 8. They should all start at 1.


Then I tried putting XPATH expressions in notfirst title context in <sys>. I have tried: count(title)+1 which just returned 1 for all titles.


count(preceding::sys[title])+1, count(../preceding-sibling::sys[title])+1, count(../preceding-sibling::*[title])+1, count(../preceding-sibling::title)+1 incremented for each <sys> but each title was numbered the same, i.e. all the titles in the first <sys> were numbered 1, all the titles in the second <sys> were numbered 2, etc.


This is what it should look like for two <sys>:


<sys>


Title (This is the first title in <sys>)
1. Title 2:
a. text
b. text
c. text
d. text

2. TItle 3
a. text
b. text

3. Title 4
a. text
b. text
c. text


</sys>


<sys>


Title
1. Title 2:
a. text
b. text
c. text

2. TItle 3
a. text
b. text
c. text


3. Title 4
a. text
b. text
c. text
d. text


</sys>


In Reply to Brandon Ibach:


I think a little more context would help. This is for numbering in Styler?
If so, are you sure you need to use XPath to get what you want? I suspect
Styler can do it without an XPath expression (even if it will compile it to
an XPath expression for certain outputs, anyway). Where are you trying to
put the XPath in (what element/context, which field/dialog, etc.) and what
XPath expressions have you tried, there?

If it's not for Styler, then what is the context?

Also, just for clarity, can you indicate what the desired result would be
for each case in your example?

-Brandon 🙂


On Tue, May 15, 2012 at 12:34 AM, Caroline Leccese <
@caroline@thecodesource.net> wrote:

> <index><title></title><tgroup></tgroup>
>
> <sys>
> <title></title> <-- The
> first title in every <sys> does not get included in numbering
> *<title></title>*
> <part>
> <item><label></label><para></para></item>
> <location></location></part>
> <part>
> <item><label></label><para></para></item>
> <location></location></part>
> <part>
> <item><label></label><para></para></item>
> <location></location></part>
> <part>
> <item><label></label><para></para></item>
> <location></location></part>
> <part>
> <item><label></label><para></para></item>
> <location></location></part>
> *<title></title>*
> <part>
> <item><label></label><para></para></item>
> <location></location></part>
> <part>
> <item><label></label><para></para></item>
> <location></location></part>
> </sys>
>
> <sys>
> <title></title> <-- The
> first title in <sys> does not get included in numbering
> *<title></title>*
> <part>
> <item><label></label><para></para></item>
> <location></location></part>
> *<title></title>*
> <part>
> <item><label></label><para></para></item>
> <location></location></part>
> <part>
> <item><label></label><para></para></item>
> <location></location></part>*
> <title></title>*
> <part>
> <item><label></label><para></para></item>
> <location></location></part>
> <part>
> <item><label></label><para></para></item>
> <location></location></part>
> </sys>
>
> </index>
>
> I want to number the titles in <sys>, excluding the first title. There are
> multiple <sys> tags and multiple <titles> within <sys>.
>
> I would have thought I could do this myself, but all I'm getting is "0".
> Thanks!
>

Keep in mind that an element styled as "Title" that is a child of a "Formal
Block" or "Division" will have the numbering applied to the parent.
Applying an XPath override, however, will apply the XPath in the context
of the title element itself.

So, setting the "first" context to no numbering and applying an XPath
override of "count(preceding-sibling::title)" to the "not first" context
should get you what you want.

-Brandon 🙂


On Tue, May 15, 2012 at 6:40 PM, Caroline Leccese <
caroline@thecodesource.net> wrote:

> Sure Brandon, this is for Styler 5.4. I am not sure I need to use XPATH,
> it seemed the easiest way to go. I want the titles numbered in <sys>,
> ignoring the first title, and I want them to restart for each <sys>
>
> I made <sys> a formal block and created two contexts, first title in <sys>
> and not first title in <sys> and added the gentext title number to not
> first title. I don't think the logic is correct. Without using XPATH, the
> titles in the first <sys> are all numbered 1. In the second <sys>, title
> numbering starts at 2 and increments to 7 so that the third <sys> starts at
> 8. They should all start at 1.
>
> Then I tried putting XPATH expressions in notfirst title context in <sys>.
> I have tried: count(title)+1 which just returned 1 for all titles.
>
> count(preceding::sys[title])+1, count(../preceding-sibling::sys[title])+1,
> count(../preceding-sibling::*[title])+1,
> count(../preceding-sibling::title)+1 incremented for each <sys> but each
> title was numbered the same, i.e. all the titles in the first <sys> were
> numbered 1, all the titles in the second <sys> were numbered 2, etc.
>
> This is what it should look like for two <sys>:
>
> <sys>
>
> Title (This is the first title in <sys>)
> 1. Title 2:
> a. text
> b. text
> c. text
> d. text
>
> 2. TItle 3
> a. text
> b. text
>
> 3. Title 4
> a. text
> b. text
> c. text
>
> </sys>
>
> <sys>
>
> Title
> 1. Title 2:
> a. text
> b. text
> c. text
>
> 2. TItle 3
> a. text
> b. text
> c. text
>
> 3. Title 4
> a. text
> b. text
> c. text
> d. text
>
> </sys>
>
> In Reply to Brandon Ibach:
>
> I think a little more context would help. This is for numbering in Styler?
> If so, are you sure you need to use XPath to get what you want? I suspect
> Styler can do it without an XPath expression (even if it will compile it to
> an XPath expression for certain outputs, anyway). Where are you trying to
> put the XPath in (what element/context, which field/dialog, etc.) and what
> XPath expressions have you tried, there?
>
> If it's not for Styler, then what is the context?
>
> Also, just for clarity, can you indicate what the desired result would be
> for each case in your example?
>
> -Brandon 🙂
>
>
> On Tue, May 15, 2012 at 12:34 AM, Caroline Leccese <
> caroline@thecodesource.net> wrote:
>
> > <index><title></title><tgroup></tgroup>
> >
> > <sys>
> > <title></title> <-- The
> > first title in every <sys> does not get included in numbering
> > *<title></title>*
>
> > <part>
> > <item><label></label><para></para></item>
> > <location></location></part>
> > <part>
> > <item><label></label><para></para></item>
> > <location></location></part>
> > <part>
> > <item><label></label><para></para></item>
> > <location></location></part>
> > <part>
> > <item><label></label><para></para></item>
> > <location></location></part>
> > <part>
> > <item><label></label><para></para></item>
> > <location></location></part>
> > *<title></title>*
>
> > <part>
> > <item><label></label><para></para></item>
> > <location></location></part>
> > <part>
> > <item><label></label><para></para></item>
> > <location></location></part>
> > </sys>
> >
> > <sys>
> > <title></title> <-- The
> > first title in <sys> does not get included in numbering
> > *<title></title>*
>
> > <part>
> > <item><label></label><para></para></item>
> > <location></location></part>
> > *<title></title>*
>
> > <part>
> > <item><label></label><para></para></item>
> > <location></location></part>
> > <part>
> > <item><label></label><para></para></item>
> > <location></location></part>*
> > <title></title>*
>
> > <part>
> > <item><label></label><para></para></item>
> > <location></location></part>
> > <part>
> > <item><label></label><para></para></item>
> > <location></location></part>
> > </sys>
> >
> > </index>
> >
> > I want to number the titles in <sys>, excluding the first title. There
> are
> > multiple <sys> tags and multiple <titles> within <sys>.
> >
> > I would have thought I could do this myself, but all I'm getting is "0".
> > Thanks!
> >
>
cleccese
5-Regular Member
(To:cleccese)

Thanks Brandon! That worked.

Announcements