2016-01-14 31 views
0

我希望我能夠計算ePub中最高div的前兄弟姐妹(腳註)。我需要在通過XSLT傳遞註釋之前將值傳遞給屬性。XQuery - 計算父親的前同胞

for $note in doc('/db/custom_jh/bukwor.xml')//tei:note[@place='bottom'] 
let $parent := count($note[preceding-sibling::tei:div[@n='1']]) 
let $update := update insert attribute att2 {$parent} into $note 
return $note 

嘗試與$note[preceding-sibling::tei:div[@n='1']]$note[ancestor-or-self::tei:div[@n='1']]回報只是0或所有的div的總和。

如果可能的話,就像XSLT中的<xsl:number level="any" select="tei:div[@n='1']/>"一樣。

UPDATE 計數(仍然沒有工作的很小的代碼,只返回6×1,應至少在一個2

for $note at $count in doc('/db/custom_jh/bukwor.xml')//tei:note[@place='bottom'] 
let $parent := count($note[ancestor-or-self::*/tei:div[@n='1']]) 
return $parent 
+0

用您想要選擇的內容的具體示例發佈示例XML。它使我們更容易實驗和驗證解決方案。 –

+0

請用示例文檔,預期和當前(錯誤)輸出更新問題。 –

回答

0

整個例子有點不好。最後,我重組了整個事情。目前,我做這種方式:

let $chaps := 
(
    let $countAll := count($doc//tei:note) 
    for $chapter at $count in $doc//tei:div[@n='1'] 
    let $countPreceding := count($chapter/preceding::tei:div[@n='1']//tei:note[@place='bottom']) 
    let $params := 
    <parameters> 
     <param name="footnoteNo" value="{$countPreceding}"/> 
    </parameters> 
    return 
    <entry name="OEBPS/chapter-{$count}.xhtml" type="xml"> 
     { 
     transform:transform($chapter, doc("/db/custom_jh/xslt/style-web.xsl"), $params) 
     } 
    </entry> 
) 

count($chapter/preceding::tei:div[@n='1']//tei:note[@place='bottom'])的伎倆我。 (我需要收集一個文件中的所有腳註,並在不同的文件中反向鏈接其索引的位置)。

0

我不知道XML的ePub格式有是提供這樣的要求沒有示例XML是不明確的,至少對我來說不過根據標題,你可能會想是這樣的:

let $parent := count($note/parent::*/preceding-sibling::tei:div[@n='1']) 

BAS從當前$note的父元素開始統計前同胞tei:div,其中tei:div具有n屬性值等於1

+0

非常感謝!我很抱歉我沒有提供任何代碼(我認爲我沒有幫助)。問題是筆記可能發生在任何級別的文本上。他們每個人都有自己的ID,但我需要傳遞一些父母的章節號或ID給它,然後才能將它們全部提取到另一個文件(用於保留用於反向鏈接的信息)。目前,提供的路徑仍然返回'0'。測試文件在這裏:[鏈接](http://46.28.111.241:8081/exist/rest/db/custom_jh/bukwor.xml) –