I.Решение XSLT 1.0 :
Это преобразование :
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match=
"location_cost[not(translate(cost_to_user, ',', '.')
>
translate(/*/patron_max_cost, ',', '.')
)
]
"/>
</xsl:stylesheet>
при применении к предоставленному документу XML :
<t>
<patron_max_cost><![CDATA[1,00]]></patron_max_cost>
<service_costs>
<location_cost>
<location_desc><![CDATA[location1]]></location_desc>
<cost_to_user><![CDATA[0,99]]></cost_to_user>
</location_cost>
<location_cost>
<location_desc><![CDATA[location2]]></location_desc>
<cost_to_user><![CDATA[1,50]]></cost_to_user>
</location_cost>
</service_costs>
</t>
дает желаемый результат :
<t>
<patron_max_cost>1,00</patron_max_cost>
<service_costs>
<location_cost>
<location_desc>location2</location_desc>
<cost_to_user>1,50</cost_to_user>
</location_cost>
</service_costs>
</t>
II.Решение XSLT 2.0:
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:variable name="vpatron_max_cost" as="xs:decimal"
select="xs:decimal(translate(/*/patron_max_cost, ',', '.'))"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match=
"location_cost[xs:decimal(translate(cost_to_user, ',', '.'))
le
$vpatron_max_cost
]
"/>
</xsl:stylesheet>