2012-11-08 13 views
2

我通過下面的XML作爲PARAM到下面我的XSL(通過Java)節點設置。XML作爲參數去XSL過去了,無法轉換爲使用DataPower的

<roles><role>USA</role><role>GB</role><role>EU</role></roles> 

我不能讓它來評估,但如果我定義一個變量中完全相同的xml字符串,它工作正常。

我正在使用Datapower。

這裏是我的XSL:

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

<xsl:param name="roles"/> 

<xsl:variable name="roles2"><roles><role>USA</role><role>GB</role><role>EU</role></roles></xsl:variable> 

<xsl:template match="/"> 

    <xsl:if test="exslt:node-set($roles)/roles/role = 'GB'"> 
     YES 1 
    </xsl:if> 

    <xsl:if test="exslt:node-set($roles2)/roles/role = 'GB'"> 
     YES 2 
    </xsl:if> 

    <xsl:if test="$roles2/roles/role = 'GB'"> 
     YES 3 
    </xsl:if> 

    roles = <xsl:value-of select="$roles" /> 
    roles2 = <xsl:value-of select="$roles2" /> 

</xsl:template> 

當我運行它,我得到以下輸出:

YES 2 YES 3 roles = <roles><role>USA</role><role>GB</role><role>EU</role></roles> roles2 = USAGBEU 

有人可以幫助我明白髮生了什麼,以及如何修復它是1出現?

謝謝。

+0

轉換的調用者必須解析(加載)字符串併產生一個XML文檔* object *。這是必須作爲'roles'參數傳遞的對象。 –

+0

我正在與@ user1810292解決此問題。所以我假設它不可能做到這一點,並沒有解決方法?感謝您的回覆 – topcat3

回答

1

當你把它作爲一個參數,它是一個字符串值,而不是一個節點集。即它不被解析爲XML。 AFAIK有沒有辦法做到這一點上XSLT1或2

0

您可以使用exsl:節點集來克服這個問題。

+1

嗨穆罕默德,歡迎來到SO並感謝您的幫助!考慮添加有關此解決方案如何解決問題的詳細信息。請參閱http://stackoverflow.com/help/how-to-answer。 –