11

I have an xml file I wish to transform using an xsl-document, but I can't seem to make it work on even the latest available Android versions.

I tried adding a <?xml-stylesheet/> tag to the xml, but that didn't work in either the native browser or in Dolphin Browser.

E.g:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="style.xsl"?>
<xmldata>Hello world</xmldata>

and

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/xmldata">
        <em><xsl:value-of select="/xmldata"/></em>
    </xsl:template>
</xsl:stylesheet>

is supposed to generate italic text, which it does in most desktop browsers (chrome has that annoying shared script root policy that ensures it only works when the files are not located on a local disc.) But it won't work in the mobile browser.

Is there a way to script the transform to happen client-side, or is the only option to do it server-side?

Zaz
  • 3,017
  • 2
  • 21
  • 28

8 Answers8

2

I have a site completely developed with XML, XSLT and XHTML. It does not render in my Android DroidX phone but renders in all the browsers elsewhere. I have no definitive answer as to if this means Android does not support XSLT.

Rob
  • 14,746
  • 28
  • 47
  • 65
  • to save CPU cycles maybe to protect battery?! I'm just rendering on serverside for Android. I do detection in Java with WURLF and then just apply the transformation just for this case to keep server processing to minimum. – Stef Mar 05 '12 at 02:14
2

See Android issue 9312 To summarize: Android browser does not support XSLT client-side until 2.1.

rds
  • 26,253
  • 19
  • 107
  • 134
  • I have version 2.2.1, so the problem seems to linger. Alternatively there exists a way to perform the transform browser side using javascript, and it's just the tag-linked transform that is malfunctioning. – Zaz Nov 29 '10 at 12:40
  • 1
    In the issue they mention that they tested it even in the latest Honeycomb SDK and it still doesn’t work. – Laurens Holst Feb 24 '11 at 14:31
  • I've got Android 2.3 and it's still not working. Apparently it works on Firefox now, whereas a few months ago it didn't. Hopefully Google will add support for it soon as well. – Stef Mar 05 '12 at 02:12
  • Dolphin Browser has recently been updated and it can do it now. – Timwi Sep 22 '13 at 10:41
1

Works fine in Opera mini. I am using Android 1.5 tablet.

Dan Peirce
  • 11
  • 1
1

The default Android Browser starts supporting xsl transforms in the version that shows up in Android 4.0, Ice Cream Sandwich.

Other mobile browsers that have finally started supporting xsl are Opera Mobile and the Chrome Android Browser, currently in beta.

Zaz
  • 3,017
  • 2
  • 21
  • 28
0

Yes, It very much is since the Android platform incorporates the Webkit layout engine.

And to my knowledge it does support XSLT. I am sure of desktop versions of webkit but you can also take a look at WebKit's XSLT implementation for in-depth info.

Robin Maben
  • 22,194
  • 16
  • 64
  • 99
  • When I visit the demo page http://www.mozilla.org/projects/xslt/test.xml linked from that page on my mobile browser, it wont render a transformed xml page, so I guess the answer is no? – Zaz Nov 25 '10 at 09:43
  • @Zaz: Have you tried using just the xmlns:xsl="http://www.w3.org/1999/XSL/Transform". XSLT processors(browsers) are very sensitive to namespace declarations. – Robin Maben Nov 25 '10 at 10:29
  • 1
    webkit mobile and webkit are not exactly the same engines – rds Nov 29 '10 at 10:52
  • assuming the left-out protocol in the namespace is a typo ^^, no. Still no dice. In addition: Desktop browser side effects of that includes xhtml elements not rendering as they are supposed to. – Zaz Nov 29 '10 at 12:36
  • I have written a testcase myself to confirm that it does not work. See also rds’s answer. – Laurens Holst Feb 24 '11 at 14:30
0

Webkit does have XSLT functionality through the use of the included libxslt library. I have successfully done transforms using the stylesheet declaration as well as using the Javascript XSLTProcessor class. This works in most webkit browsers except for Android and iPhone.

It seems that to save space they have purposely disabled the xslt functionality and my guess would be that it was a an optimization done for mobile browsers.

Tested using Android 2.2 on the Galaxy Tablet and the XSLTProcessor class does not exist.

dalore
  • 5,594
  • 1
  • 36
  • 38
0

I just tested an XSLT example with Froyo browser and the result is a totally white page. However I installed Opera mobile browser for Android and it renders my example perfectly.

I cannot test in Opera mini because my test is served in a no internet accesible LAN.

Patxitron
  • 435
  • 4
  • 8
0

I downloaded Opera Mobile Version: 12.00 for my Desire and XSLT finally works on my phone. So a great tip is to download Opera Mobile in Market.

Viktor Kuznyetso
  • 57
  • 1
  • 1
  • 4