2008-12-16 61 views
1

我怎麼能算多少以前FootNoteReference節點有一個XML文檔,如這以前的元素)等於「FootNoteReference」 ......計算已本地名(

<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節點是如何嵌套在不同層次的。我知道他們是否都嵌套在我可以做的相同的水平上:count(preceding-sibling::*[local-name() = 'FootNoteReference'])

謝謝!

回答

4

使用"preceding" axis

                count($vNode/preceding::FootNoteReference)

是先通過$vNode引用的節點FootNoteReference元件的數量。

如果節點是任何FootNoteReference元素的後代,你想也算它的祖先FootNoteReference元素,則FootNoteReference元素對the "ancestor" axis的出現次數也應考慮在內,而這將通過以下XPath表達式來完成:

          count($vNode/preceding::FootNoteReference
                        |
                              $vNode/ancestor::FootNoteReference)

+0

感謝您的幫助。這個技巧:select =「count(之前的:: FootNoteReference) – joe 2008-12-17 14:48:25