2017-07-25 45 views
0

我是Java新手。我有一個類似的場景爲[Catch output stream of xsl result-document,但我不理解什麼通過爲href和基礎參數..如何在Java中實現saxon OutputURIResolver?

我的XSLT(結果文檔)如下:

<xsl:template match="/" mode="create-text-file"> 
     <xsl:param name="book-name" tunnel="yes"/> 

     <xsl:result-document href="{$book-name}.xml" 
      doctype-public=" test" 
      doctype-system="test.dtd"> 
      <xsl:apply-templates/> 
     </xsl:result-document> 
    </xsl:template> 

另:

<xsl:result-document href="{$book-name}.opf" 
          doctype-public="" 
          doctype-system="" 
          indent="yes"> 

      <xsl:apply-templates mode="#current"/> 
     </xsl:result-document> 

參數書的名字越來越爲:

<xsl:template match="document-node()"> 
     <xsl:variable name="book-name" select="tps:get-file-name(document-uri(/))"/> 

能否請您給我解釋一下無線這個結果文件?

在此先感謝。

回答

0

OutputURIResolver是一個回調:這意味着你提供解決()方法的實現,並呼籲薩克森您的實現。所以你不必擔心要傳遞什麼作爲基礎和href參數,因爲你不稱這種方法,撒克遜人會這樣做。它通常將提供在href參數作爲你的呼叫於xsl的href屬性的(擴展的)值:結果文檔,和基值將是「基地輸出URI」,默認爲提名作爲主要輸出的文件(命令行中的-o選項)。

+0

先生可以當我不使用命令行參數我們給出了一個文件夾路徑或自定義位置爲基礎?而我所理解的是,如果我們提取了xslt zip包(根據我的場景),OutputURIResolver就是獲取href值。 – user2490093

+0

如果使用s9api接口則可以使用所設置的基本輸出URI'XsltTransformer.setBaseOutputURI()'。在JAXP中沒有等價物,因爲JAXP是爲XSLT 1.0設計的。 –