定义一个全局的变量
<xsl:variable name="smallcase" select="‘abcdefghijklmnopqrstuvwxyz‘" />
<xsl:variable name="uppercase" select="‘ABCDEFGHIJKLMNOPQRSTUVWXYZ‘" />
利用 translate函数进行数据转换
例如:
<?xml version="1.0" encoding="utf-8"?>
<shipment>
? <header>
? ? <shipmentHeader>
? ? ? <sourceOrderCode>1-8hldi</sourceOrderCode>
? ? </shipmentHeader>
? ? ? </header>
</shipment>
===============================================================
<xsl:stylesheet version="1.0"
? ? ? ? ? ? ? ? xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
? ? <xsl:variable name="smallcase" select="‘abcdefghijklmnopqrstuvwxyz‘" />
? ? <xsl:variable name="uppercase" select="‘ABCDEFGHIJKLMNOPQRSTUVWXYZ‘" />
? ? <xsl:template match="/">
? ? ? ? <ListOfFtCsmPartsApproveIoWms>
? ? ? ? ? ? <FtCsmPartsApprove>
? ? ? ? ? ? ? ? <xsl:apply-templates select="//shipment/header/shipmentHeader"/>
? ? ? ? ? ? </FtCsmPartsApprove>
? ? ? ? </ListOfFtCsmPartsApproveIoWms>
? ? </xsl:template>
? ? <xsl:template match="/shipment/header/shipmentHeader">
? ? ? ? <Id><xsl:value-of select="translate(sourceOrderCode,$smallcase,$uppercase)"/></Id>
? ? </xsl:template>
</xsl:stylesheet>
============================================================
<?xml version="1.0" encoding="utf-16"?><ListOfFtCsmPartsApproveIoWms><FtCsmPartsApprove><Id>1-8HLDI</Id></FtCsmPartsApprove></ListOfFtCsmPartsApproveIoWms>
转换完之后,得到结果,会将小写转为大写
原理是translate的函数,将参数1余参数2匹配,在与参数3匹配,并留存参数3的值,