2011-12-19 71 views
1

我正在使用帶有氧氣xml編輯器的docbook5。我將通過XSLTproc和FOP去PDF。我試圖讓「版本」標籤的值顯示在頁腳中,但這不能正常工作。Docbook 5 XSLT:「編輯」元素失敗的查詢和返回值

鑑於DocBook的5來源:

<?xml version="1.0" encoding="utf-8"?> 
<!DOCTYPE book 
<book version="5.0" xmlns="http://docbook.org/ns/docbook" 
    xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" 
    xmlns:svg="http://www.w3.org/2000/svg" xmlns:m="http://www.w3.org/1998/Math/MathML" 
    xmlns:html="http://www.w3.org/1999/xhtml" xmlns:db="http://docbook.org/ns/docbook"> 
     <info> 
     <title>User Manual</title> 
     <edition>Ed. 123456</edition> 
     </info> 
</book> 

和頁腳模板:正確

<?xml version="1.0" encoding="UTF-8"?> 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:fo="http://www.w3.org/1999/XSL/Format" version="1.0"> 

<xsl:template name="footer.content"> 
    <xsl:param name="pageclass" select="''"/> 
    <xsl:param name="sequence" select="''"/> 
    <xsl:param name="position" select="''"/> 
    <xsl:param name="gentext-key" select="''"/> 

    <fo:block> 
    <!-- sequence can be odd, even, first, blank --> 
    <!-- position can be left, center, right --> 
    <xsl:choose> 

     <xsl:when test="$sequence = 'odd' and $position = 'left'"> 
     <fo:retrieve-marker retrieve-class-name="section.head.marker" 
         retrieve-position="first-including-carryover" 
         retrieve-boundary="page-sequence"/> 
     </xsl:when> 

     <xsl:when test="$sequence = 'odd' and $position = 'center'"> 
     <xsl:value-of select="ancestor-or-self::book/info/edition"/> 
     </xsl:when> 

    </xsl:choose> 
    </fo:block> 
</xsl:template> 
</xsl:stylesheet> 

的價值回報,當我從工具欄中的oxygenxml XQuery的部分查詢,而不是在我將文檔處理爲PDF。任何幫助將超級!

回答

1

您必須考慮DocBook命名空間。按照慣例,名稱空間URI被映射到樣式表中的d前綴。在您的自定義文件執行此操作:

  1. 添加

    xmlns:d="http://docbook.org/ns/docbook" 
    exclude-result-prefixes="d" 
    

    到根<xsl:stylesheet>元素。

  2. 變化

    <xsl:value-of select="ancestor-or-self::book/info/edition"/> 
    

    <xsl:value-of select="ancestor-or-self::d:book/d:info/d:edition"/>