<?xml version="1.0" encoding="UTF-8"?>
<MyXMLTree xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Node1>X</Node1>
<Node1Ext>Y</Node1Ext>
</MyXMLTree>
我想有一个XSLT将XML转换为此
<?xml version="1.0" encoding="UTF-8"?>
<MyXMLTree xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Node1>X</Node1>
<Node1Ext>1</Node1Ext>
</MyXMLTree>
If Node1 == 'X' and Node1Ext != 'X' then
Node1Ext = '1'
else if Node1 != 'X' and Node1Ext == 'X' then
Node1Ext = '2'
else if Node1 == 'X'and Node1Ext =='X' then
Node1Ext = '3'
EndIf
提前谢谢你:)
答案 0 :(得分:0)
这应该这样做。请试一试:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="Node1Ext[. = 'X' or ../Node1 = 'X']">
<xsl:copy>
<xsl:value-of select="(../Node1 = 'X') + 2 * (. = 'X')"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>