0

I have an XSL file which is successful in transforming my XML on the desktop browser. In that XSLT I am making use of the EXLT node-set() function.
On trying to transform the same XML file using the same XSL file on Android it throws me an error stating "Error in XPATH expression" and points me to the line where I am calling the node-set() function.
Any ideas on how to use xxx:node-set() in Android?

Shreyos Adikari
  • 12,348
  • 19
  • 73
  • 82
rajeev
  • 1
  • 1
  • You need to find out which XSLT processor is used, then for this XSLT processor find out the vendor-supplied namespace and extension function name to use in converting an RTF to a node-set. – Dimitre Novatchev Aug 07 '12 at 11:51
  • Appreciate your response. I couldnt find anything published on the same. I had tried using both the EXSLT and the Xalan namespaces with the code earlier with the same error. I thought there would have been some way in which I could call an Android function from the XSLT to achieve the same but I was unable to get that working either. – rajeev Aug 07 '12 at 17:12
  • My scenario is as follows Somewhere in my XML i have a tokenized string which I need to split and then use the individual separated string to transform the XML to a HTML doc. From the forums I have come to a conclusion that I would need to create a dynamic variable which then would have to converted to a node-set before I can use XPATH on the same. Please let me know if I am missing anything or if there is another way around it. At this moment I would be willing to try out anything. – rajeev Aug 07 '12 at 17:16
  • rajeev, The only thing we need to know is what XSLT processor (Vendor) you are using. – Dimitre Novatchev Aug 07 '12 at 17:56
  • Put `` in a stylesheet, and see what it generates. – Flynn1179 Aug 07 '12 at 18:49
  • I took @Flynn1179 advice. The value I get is **"Apache Software Foundation"**. Am assuming that means its the Xalan processor ?? – rajeev Aug 08 '12 at 06:56

2 Answers2

0

Android use LibXML2, so there are a hasExsltSupport() method. If enabled, use as showed by http://www.exslt.org/exsl/index.html

Peter Krauss
  • 13,174
  • 24
  • 167
  • 304
  • I am also facing the same issue while using 'node-set' in my xsl file. It works on desktop but not on android because android uses 'xalan' xslt processor. I have included xalan-java jars as well to my android project (xalan.jar, serializer.jar, xercesImpl.jar, xml-apis.jar) but no luck. How to test whether 'hasExsltSupport' enabled? Which class this method is in and how to test for that. Also, if is is not enabled, how to enable it? – Amit Apr 16 '17 at 13:43
0

Android uses Xalan. I have not managed to get Android Studio to build with exslt extensions declared, but the xalan namespace functions build after downloading namespace declarations. Unfortunately, it still throws errors:

javax.xml.transform.TransformerException: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object org.apache.xalan.extensions.ExtensionsTable.extFunction(org.apache.xpath.functions.FuncExtFunction, java.util.Vector, org.apache.xalan.extensions.ExpressionContext)' on a null object reference

This seems like a bug because the context is supposed to come from the processor, xsl only supplies the param/variable.

sgc
  • 45
  • 1
  • 7