Consider previous items that have a local name () equal to 'FootNoteReference'
How to count the number of previous FootNoteReference nodes in an XML document like ...
<MyDoc>
<title><Big Title></title>
<head>Objective</head>
<head2><Heading></head2>
<head>Introduction</head>
<Para>
asdf asdf asdf asd<FootNoteReference />asdf asdf asfd asfd
</Para>
<head>Overview</head>
<Para>
<Begin with a definition of the class to which<FootNoteReference /> the categories belong, if required.>
</Para>
<Para><List the different categories to be taught.></Para>
<Heading1><Category 1></Heading1>
<Para>< som neodolal a celé ozdobené spústou prachu v jednom preso></Para>
<Para><Provide examples, if required.></Para>
<Heading1><Category 2></Heading1>
<Para>< som neodolal a celé ozdobené spústou prachu v jednom preso></Para>
<Para><Provide examples, if required.></Para>
<Heading1><Category 3></Heading1>
<Para>
<Provide a description<FootNoteReference /> of the third category as outlined in the list.>
</Para>
<Para><Provide examples, if required.></Para>
<head>Summary</head>
<ListItem type="ul"><Summarize the definition, if applicable.></ListItem>
<ListItem type="ul">< som neodolal a celé ozdobené spústou prachu v jednom preso<FootNoteReference />.></ListItem>
<ListItem type="ul">< som neodolal a celé ozdobené spústou prachu v jednom preso></ListItem></MyDoc>
Note that the FootNoteReference node is nested at different levels. I know if they are all nested at the same level as me:count(preceding-sibling::*[local-name() = 'FootNoteReference'])
Thank!
source to share
Use the " preceding
" axis :
count($vNode/preceding::FootNoteReference)
- the number of elements FootNoteReference
that precede the node being referenced $vNode
.
If node is a descendant of any element FootNoteReference
, and you also want to count its parent elements FootNoteReference
, then the occurrences of the element are FootNoteReference
on the " ancestor
" axis , and this will be done with the following XPath expression:
count($vNode/preceding::FootNoteReference
|
$vNode/ancestor::FootNoteReference)
source to share