2
所以我有一个条件改造这个XSL如果温度> 20移除标签以其他方式复制温度 到目前为止,我有这样的事情XSL删除标签,如果温度> 20以其他方式复制标签
<?xml version="1.0" ?>
<message-in>
<realised-gps>
<id>64172068</id>
<resourceId>B-06- KXO</resourceId>
<position>
<coordinatesystem>Standard</coordinatesystem>
<latitude>44.380765</latitude>
<longitude>25.9952</longitude>
</position>
<time>2011-05- 23T10:34:46</time>
<temperature>21.01</temperature>
<door>0</door>
</realised-gps>
</message-in>
这只是去除标签,我不能让其他方式或其他if条件
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="temperature">
<xsl:if test="temperature > 20">
<xsl:apply-templates />
</xsl:if>
<xsl:if test="temperature <= 20">
<xsl:copy>
<xsl:apply-templates select="//temperature|node()"/>
</xsl:copy>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
温度<预期输出文件超过20
<?xml version="1.0" ?>
<message-in>
<realised-gps>
<id>64172068</id>
<resourceId>B-06- KXO</resourceId>
<position>
<coordinatesystem>Standard</coordinatesystem>
<latitude>44.380765</latitude>
<longitude>25.9952</longitude>
</position>
<time>2011-05- 23T10:34:46</time>
<temperature>15</temperature>
<door>0</door>
</realised-gps>
</message-in>
感谢的人它完美的作品!也感谢您的教训! – orosco03