2012-05-16 29 views
2

我想在基於Saxon的xslt轉換中使用歸類。源文件:XSL/Saxon歸類/命令行

<root> 
    <entry name="B" /> 
    <entry name="Aa" /> 
    <entry name="Ä" /> 
    <entry name="Az" /> 
</root> 

和我的轉型:

<xsl:stylesheet version="2.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:saxon="http://saxon.sf.net/"> 
    <xsl:output indent="yes"/> 

    <saxon:collation name="german" lang="de-DE"/> 

    <xsl:template match="root"> 
     <root> 
     <xsl:for-each select="entry"> 
      <xsl:sort select="@name" collation="german"/> 
      <sorted entry="{@name}"/> 
     </xsl:for-each> 
     </root> 
    </xsl:template> 

</xsl:stylesheet> 

這工作幾乎罰款,對氧輸出是:

<root xmlns:saxon="http://saxon.sf.net/"> 
    <sorted entry="Ä"/> 
    <sorted entry="Aa"/> 
    <sorted entry="Az"/> 
    <sorted entry="B"/> 
</root> 

(在A應該是第二項,但這是另一個問題,我猜)

但是,當我使用命令行,我得到一個錯誤:

java -jar saxon9he.jar -s:source.xml -o:out.xml -xsl:transformation.xsl 


    XTDE1035: Collation file:/Users/<mypath>/german has not been defined 
Failed to compile stylesheet. 1 error detected. 

看起來好像撒克遜現在想用german作爲文件。它不存在。


問題是:如何在命令行上使用此樣式表。

如果合適,我還會問如何得到兩個「A」之間的「Ä」。條目,但我可以在另一個問題中提出這個問題。

回答

3

最簡單的解決方法是不使用排序屬性可言,但使用

<xsl:sort lang="de"/> 

它要求系統找到適合德國文本整理,並且是跨XSLT處理器便攜。

如果你想更精確的整理,對在這裏建造撒克遜整理的URI指導:http://www.saxonica.com/documentation/extensibility/collation.xml

原因你的錯誤是,當你指定的值是一個相對的URI引用,它被解釋爲相對於樣式表的基本URI。使用撒克遜時,這幾乎不可避免地會產生一個不存在的排序規則URI。目前還不清楚爲什麼該規範允許相對整理URI;他們可能對某些產品有用,但他們對撒克遜沒有任何用處。