Is the Android Browser capable of performing an xs

2020-02-28 04:56发布

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?

8条回答
在下西门庆
2楼-- · 2020-02-28 04:59

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.

查看更多
Anthone
3楼-- · 2020-02-28 05:00

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.

查看更多
你好瞎i
4楼-- · 2020-02-28 05:11

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.

查看更多
何必那么认真
5楼-- · 2020-02-28 05:14

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

查看更多
【Aperson】
6楼-- · 2020-02-28 05:15

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.

查看更多
孤傲高冷的网名
7楼-- · 2020-02-28 05:22

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

查看更多
登录 后发表回答