Xslt 计算本地-name()等于“FootNoteReference”的先前元素

Xslt 计算本地-name()等于“FootNoteReference”的先前元素,xslt,Xslt,如何计算像这样的xml文档中有多少以前的脚注引用节点 <MyDoc> <title>&lt;Big Title&gt;</title> <head>Objective</head> <head2>&lt;Heading&gt;</head2> <head>Introduction</head> <Para> asdf asdf asdf

如何计算像这样的xml文档中有多少以前的脚注引用节点

<MyDoc>
<title>&lt;Big Title&gt;</title>
<head>Objective</head>
<head2>&lt;Heading&gt;</head2>
<head>Introduction</head>
<Para>
    asdf asdf asdf asd<FootNoteReference />asdf asdf asfd asfd 
</Para>
<head>Overview</head>
<Para>
    &lt;Begin with a definition of the class to which<FootNoteReference /> the categories belong, if required.&gt;
</Para>
<Para>&lt;List the different categories to be taught.&gt;</Para>
<Heading1>&lt;Category 1&gt;</Heading1>
<Para>&lt; som neodolal a celé ozdobené spústou prachu v jednom preso&gt;</Para>
<Para>&lt;Provide examples, if required.&gt;</Para>
<Heading1>&lt;Category 2&gt;</Heading1>
<Para>&lt; som neodolal a celé ozdobené spústou prachu v jednom preso&gt;</Para>
<Para>&lt;Provide examples, if required.&gt;</Para>
<Heading1>&lt;Category 3&gt;</Heading1>
<Para>
    &lt;Provide a description<FootNoteReference /> of the third category as outlined in the list.&gt;
</Para>
<Para>&lt;Provide examples, if required.&gt;</Para>
<head>Summary</head>
<ListItem type="ul">&lt;Summarize the definition, if applicable.&gt;</ListItem>
<ListItem type="ul">&lt; som neodolal a celé ozdobené spústou prachu v jednom preso<FootNoteReference />.&gt;</ListItem>
<ListItem type="ul">&lt; som neodolal a celé ozdobené spústou prachu v jednom preso&gt;</ListItem></MyDoc>
注意FootNoteReference节点是如何嵌套在不同级别的。我知道它们是否都嵌套在同一级别,我可以这样做:countprevious sibling::*[local name='FootNoteReference']

谢谢

使用:

count$vNode/previous::FootNoteReference

是$vNode引用的节点之前的脚注引用元素数

如果节点是任何FootNoteReference元素的后代,并且您还希望计算其祖先FootNoteReference元素的数量,则还应考虑FootNoteReference元素在上的出现,这将通过以下XPath表达式完成:

count$vNode/previous::FootNoteReference |$vNode/祖先::FootNoteReference

使用:

count$vNode/previous::FootNoteReference

是$vNode引用的节点之前的脚注引用元素数

如果节点是任何FootNoteReference元素的后代,并且您还希望计算其祖先FootNoteReference元素的数量,则还应考虑FootNoteReference元素在上的出现,这将通过以下XPath表达式完成:

count$vNode/previous::FootNoteReference
|$vNode/祖先::FootNoteReference

感谢您的帮助。这就成功了:select=countpreference::footnoteReference感谢帮助。这就成功了:select=countprevious::FootNoteReference