2011-12-16 27 views
1

xmlをjava/xalan(2.7.1)でorgに変換しようとしています。 apache.xalan.xslt.Processクラスxsltエラー:余分な不正なトークン:xalan/java経由でxsl/xslt経由でxmlを変換すると、 'eq'、 'center' 'が返される

私は「エクストラ違法トークン」を取得しています

と私は基本的にテンプレートにパラメータを渡し、その後、属性として、そのパラメータを使用したい

周りの仕事がわかりません<xsl:when test="$textAlign eq 'center'">

私が'center' paramをTableCellテンプレートに渡すと、テキストが中央に配置されたテーブルセルを作成したいと思いますの内容は左揃えになります。

エラーメッセージが中央の旅、それを周りに'center'

引用符不満、それは大丈夫でなければなりませんように思えるされます。ここ

は、いくつかのスニペット(サンプルXMLとXSL)

<ingredients>   
      <ingredient> 
       <quantity>1 1/2</quantity> 
       <foodstuff>flour</foodstuff> 
      </ingredient> 
    </ingredients> 

であり、ここではサンプルXSL

<xsl:output method="html"/> 
<xsl:template match="ingredients"> 
     <xsl:apply-templates select="ingredient"/> 
</xsl:template> 
. 
<xsl:template match="ingredient"> 
    <xsl:call-template name="TableCell"> 
     <xsl:with-param name="cellValue" select="quantity" /> 
     <xsl:with-param name="textAlign" select="'center'" /> 
    </xsl:call-template> 
</xsl:template> 
. 
<xsl:template name="TableCell"> 
    <xsl:param name="cellValue" /> 
    <xsl:param name="textAlign" /> 
    <xsl:choose> 
     <xsl:when test="$textAlign eq 'center'"> 
     <td align='center'> 
     <xsl:value-of select="$cellValue"/> 
     </td> 
    </xsl:when> 
    </xsl:choose> 
</xsl:template> 

は多分これを実行する別の方法はありますか?私は私のXSLエンジン

org.apache.xalan.xslt.Process -IN test.xml -XSL test.xsl -OUT out.html 

みんなありがとう

答えて

4

eqのためのXalan 2.7.1を使用しています

がで導入された演算子である私はそれは非常に簡単だと思ったが、私は、私はちょうどXSLに十分精通していないと思いますXPathとXSLT 2.0を使用している場合は、XPathとXSLT 1.0のみをサポートするXalanを使用していますので、代わりに=演算子を使用してください。 XalanからSaxon 9(http://saxon.sourceforge.net/)に移動すると、そのプロセッサはXSLT 2.0をサポートします。

+0

私は実際にPDFに変換するためにFOPを使用していますので、最新のxslt/xpath 2.0を使用したいと思うほど、JARを交換するよりも多くの作業ができると思います。お返事をありがとうございます – user825402

関連する問題