Xslt 在XSL中,如何检查模式中给定属性的数据类型

Xslt 在XSL中,如何检查模式中给定属性的数据类型,xslt,Xslt,我有一个包含日期值的XML,其中模式中给出的类型不是xs:date,而是用户定义的简单类型date\u type。 在生成的XML中,我想将类型为date\u type的所有属性的日期格式从“YYYY-MM-DD”更改为“yyyyymmdd”。 下面的链接说有办法,但我无法使用attribute(*,type)编译样式表 我的XML是: <input> <car mileage="15000" mfgDate="2012-12-31"/> <battery mfg

我有一个包含日期值的XML,其中模式中给出的类型不是xs:date,而是用户定义的简单类型date\u type。
在生成的XML中,我想将类型为date\u type的所有属性的日期格式从“YYYY-MM-DD”更改为“yyyyymmdd”。
下面的链接说有办法,但我无法使用attribute(*,type)编译样式表

我的XML是:

<input>
<car mileage="15000" mfgDate="2012-12-31"/>
<battery mfgDate="2012-03-01" expiryDate="2014-12-31"/>
     ...
</input>

...
在我的模式文件中,数据类型date_type为:

<xsd:simpleType name="date_type">
    <xsd:restriction base="xsd:string">
        <xsd:length value="8"/>
    </xsd:restriction>
</xsd:simpleType>
<xsd:attribute name="mfgDate" type="sch:date_type"/>
<xsd:attribute name="expiryDate" type="sch:date_type"/>

mfgDate和expiryDate也是日期类型,如下所示:

<xsd:simpleType name="date_type">
    <xsd:restriction base="xsd:string">
        <xsd:length value="8"/>
    </xsd:restriction>
</xsd:simpleType>
<xsd:attribute name="mfgDate" type="sch:date_type"/>
<xsd:attribute name="expiryDate" type="sch:date_type"/>

预期产出为:

<input>
<car mileage="15000" mfgDate="20121231"/>
<battery mfgDate="20120301" expiryDate="20141231"/>
     ...
</input>

...
是否有方法检查所有此类类型的属性数据类型,并执行如下字符串操作:

<xsl:template match="attribute(*,sch:date_type)">
    <xsl:value-of select="translate(.,'-','')"/>
</xsl:template>


行上属性(*,sch:date\u type)出现语法错误TransformerConfiguration异常:无法编译样式表。

您使用的XSLT处理器是什么?像这样的类型化测试需要一个支持模式的XSLT2.0处理器,比如Saxon EE。随IBM WebSphere的XML功能提供的XSLT处理器(从WebSphere Application Server 8.5开始,它只是作为基本产品的一部分提供的)也支持XSLT2.0。。。。是的,您需要XSLT2.0来访问类型信息。