Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xslt XSL更改参数的值_Xslt_Parameters - Fatal编程技术网

Xslt XSL更改参数的值

Xslt XSL更改参数的值,xslt,parameters,Xslt,Parameters,看一下我的XML(简化): 我要做的是将值“xs:double”更改为“doubleOrEmpty”,这是我的自定义类型,允许使用double和空字符串。可以使用XSL吗?如果不是,我如何实现这一点呢?当然,您可以编写XSLT来进行转换 <head xmlns:xs="http://www.w3.org/2001/XMLSchema"> <body> <xs:element type="xs:double"/> </body> </hea

看一下我的XML(简化):



我要做的是将值“xs:double”更改为“doubleOrEmpty”,这是我的自定义类型,允许使用double和空字符串。可以使用XSL吗?如果不是,我如何实现这一点呢?

当然,您可以编写XSLT来进行转换

<head xmlns:xs="http://www.w3.org/2001/XMLSchema">
<body>
<xs:element type="xs:double"/>
</body>
</head>


与:


双倍
<head xmlns:xs="http://www.w3.org/2001/XMLSchema">
<body>
<xs:element type="xs:double"/>
</body>
</head>
<head xmlns:xs="http://www.w3.org/2001/XMLSchema">
<body>
<xs:element type="doubleOrEmtpy"/>
</body>
</head>
<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  version="1.0"
  xmlns:xs="http://www.w3.org/2001/XMLSchema">

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

<xsl:template match="body/xs:element/@type[. = 'xs:double']">
  <xsl:attribute name="type">doubleOrEmtpy</xsl:attribute>
</xsl:template>

</xsl:stylesheet>