2015-06-09 30 views
0

我會在android系統轉換XML使用XSLT和代碼片段如下:android xml轉換錯誤:xsl:variable的select標籤中有多個值?

private String convertMathml2Svg() { 
    String result = ""; 
    try { 
     Source xmlSource = new StreamSource(this.getResources().openRawResource(R.raw.testxml)); 
     Source xsltSource = new StreamSource(this.getResources().openRawResource(R.raw.testxsl)); 
     TransformerFactory transFact = TransformerFactory.newInstance(); 
     Transformer trans = transFact.newTransformer(xsltSource); 
     Writer writer = new StringWriter(); 
     StreamResult resultStream = new StreamResult(writer); 
     trans.transform(xmlSource, resultStream); 
     result = writer.toString(); 
    } catch (Exception e) { 
     Log.d(LOG_TAG, "EXCEPTION: " + e); 
     result = ""; 
    } 
    return result; 
} 
當我在Android 4.4上運行此

,它如下提示錯誤:

W/System.err﹕ SystemId Unknown; Line #472; Column #2; Expected), but found: , 

的XSL代碼給出了這樣的錯誤是:

<xsl:variable name="XXX" select="('A', 'B', 'C')"/> 

似乎變壓器不承認「」後‘A’,並期望它‘)’。

我不熟悉XSL語法,所以我請求任何幫助。

非常感謝!

回答

0

不知道你想用$XXX做什麼。要創建您可以使用

<xsl:variable name="XXX" select="unordered('A','B','C')"/> 

列表,但它需要的XPath 2.0(XSL 2.0自帶的XPath 2.0)。我不知道如果Android實現支持它。您可能會嘗試將version="2.0"添加到您的xsl:stylesheet標記中。

最好的問候 Majo