首页 文章

我们必须为模板标签中的匹配赋予什么 Value ?

提问于
浏览
2

源xml文件:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!-- Inbound Message -->
<Sales xmlns="abc:org.xcbl:schemas/xcbl/v4/xcbl4.xsd" xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding">
</Sales>

代码:

<?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

    <xsl:template match="/Sales">
    </xsl:template>

查询:在源xml中,Sales根节点标记包含以下值 . xmlns =“abc:org.xcbl:schemas / xcbl / v4 / xcbl4.xsd”xmlns:SOAPENV =“http://www.w3.org/2003/05/soap-envelope”xmlns:xsi =“http:/ /www.w3.org/2001/XMLSchema-instance“xmlns:SOAP-ENC =”http://www.w3.org/2003/05/soap-encoding如何启动模板?

<xsl:template match="/Sales'> 
<xsl:template match="/'>

以上代码无效 . 请帮我解决这个问题

.

1 回答

  • 1

    在XSLT中声明名称空间,然后使用限定名称,例如:

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                    xmlns:ns="abc:org.xcbl:schemas/xcbl/v4/xcbl4.xsd">
    
        <xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes"/>
    
        <xsl:template match="/ns:Sales">
        </xsl:template>
    
    </xsl:stylesheet>
    

相关问题