2013-05-13 57 views
-1

在我的XML看看(简体):XSL变化值

<head> 
<body> 
<xs:element type="xs:double"/> 
</body> 
</head> 

我想要做的是改变价值“XS:双”到“doubleOrEmpty”这是我的自定义类型,它允许双打和空弦。是否可以使用XSL?如果不是我怎么能做到这一点?

回答

2

那么你当然可以写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="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>