如何更改属性值

How to change an attribute value

我想将 XSD 属性 @type 的值从 xsd:boolean 更改为 xsd:string

我的XSD是

<xsd:element name="Complete" nillable="true" type="xsd:boolean"/>
<xsd:element name="taskno" nillable="true" type="xsd:integer"/>

我编写的 XSLT 将所有 @type 属性值替换为 xsd:string。我无法检查 @type 是否为 xsd:boolean

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    version="1.0">

    <xsl:param name="pNewType" select="'xsd:string'"/>

    <xsl:template match="node()|@*">
        <xsl:copy>
            <xsl:apply-templates select="node()|@*"/>
        </xsl:copy>
    </xsl:template>

    <xsl:template match="@type">
        <!-- <xsl:if test="type='xsd:boolean'">
        Found element!!*********
        </xsl:if>     --> *** Condition to check if its boolean doesn't work
        <xsl:attribute name="type">
            <xsl:value-of select="$pNewType"/>
        </xsl:attribute>
    </xsl:template>
</xsl:stylesheet>

改变

<xsl:template match="@type">

<xsl:template match="@type[ . = 'xsd:boolean']">

完整的 XSLT:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                version="1.0">

  <xsl:template match="node()|@*">
    <xsl:copy>
      <xsl:apply-templates select="node()|@*"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="@type[ . = 'xsd:boolean']">
    <xsl:attribute name="type">
      <xsl:value-of select="'xsd:string'"/>
    </xsl:attribute>
  </xsl:template>

</xsl:stylesheet>