0 Replies Latest reply: Jul 16, 2011 1:29 PM by 875949 RSS

    Calling Java Android code from XSLT

    875949
      I am trying to get an XSLT stylesheet to work that invokes Java code at certain points during execution (used to parse RDFa). You can find a very simple example of such code below:

      <?xml version="1.0" encoding="UTF-8"?>
      <stylesheet
      xmlns:xsl ="http://www.w3.org/1999/XSL/Transform" version="1.0"
      xmlns ="http://www.w3.org/1999/XSL/Transform"
      xmlns:xalan="http://xml.apache.org/xalan"
      xmlns:java="http://xml.apache.org/xalan/java"
      exclude-result-prefixes="java" >

      <xsl:template match="/">
      <value-of select="java:android.xslt_test.XSLTTest.testing()"/>
      </xsl:template>

      </stylesheet>
      Although this XSLT calls the specified method for a Java desktop application, it doesn't do anything in an Android application (no methods are called and the transformer simply returns the original document). After I configured the Transformer instance with a custom ErrorListener subclass instance (via aTransformer.setErrorListener()), I get a NullPointerException (packaged as a TransformerException) when the above XSLT code is parsed. This error does not occur for "normal" XSLT sheets (these are parsed correctly on Android).

      Any ideas on why this doesn't work? Do I need to use another prefix / namespace for Android applications? I've spent quite some time looking online for a solution, but couldn't find any..

      Thanks,

      William