我知道Android 2.x doesn't support XSL transformations和it's a known bug,但我似乎无法解决如何以任何其他方式实现此功能。我看过3rd party libraries,但似乎没有任何帮助填补这一空白。
我有需要解析的各种文件,所有工作都在Honeycomb中找到 - 所有类似于下面的代码 - 在Android 2.x上有什么办法吗?
XML:
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="Weather.xsl"?>
<!DOCTYPE rssfeed[
<!ENTITY feedData SYSTEM "http://webservice.weatherzone.com.au/rss/wx.php?lt=aploc&lc=12493&obs=1&fc=1&warn=1">
]>
<feed>
<title>weather</title>
&feedData;
</feed>
XSL:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<head>
<link rel="stylesheet" type="text/css" href="styles.css" />
<meta name="viewport" content="width=320px, initial-scale=1.0" />
</head>
<body>
<div class="content">
<br />
<h1><xsl:value-of select="feed/title"/></h1>
<xsl:apply-templates select="//item"/>
</div>
</body>
</html>
</xsl:template>
<xsl:template match="item">
<xsl:choose>
<xsl:when test="title='weather'">
</xsl:when>
<xsl:otherwise>
<h2><xsl:value-of select="title"/></h2>
<xsl:choose>
<xsl:when test="title='weather forecast'">
<div class="forecast">
<xsl:value-of select="description" disable-output-escaping="yes"/>
</div>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="description" disable-output-escaping="yes"/>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>