android XML transform error: multiple values in xsl:variable's select tag?

123 Views Asked by At

i'd transform an XML with XSLT in android, and code snippet is as follows:

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;
}

when I run this on android 4.4, it gives error as follows:

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

the xsl code which gives such error is:

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

it seems that Transformer does not recognize the "," after "A", and expect it to be ")".

i'm not familiar with XSL syntax, so i ask for any kind help.

many thanks!

1

There are 1 best solutions below

0
On

don't know what you want to do with $XXX. To create a list you may use

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

but it needs XPath 2.0 (XSL 2.0 comes with XPath 2.0). I dont't know if the android implementation supports it. You may have a try add version="2.0" to your xsl:stylesheet tag.

best regards Majo