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

标签 xml xslt xpath xslt-2.0

Source xml file:


<?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> 

Code:


 <?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>  

Query: In the source xml, Sales root node tag contains the below values. 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

How to start the template?


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

Above code is not working. Please help me to resolve this issue



.

最佳答案

在 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>

关于xml - 我们必须为模板标签中的匹配赋予什么值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7722589/

相关文章:

c# - 错误 "System.Xml.Linq.XDocument' 不包含定义是什么意思?

android - 性能不佳的 Lint 警告 - 80+ 次查看

java - 使用 SAX 解析器遍历 xml 文档并以所需格式打印输出

python - 从多个 div (selenium) 中抓取第一个 child 的属性

ruby - 如何编写一个 CSS 选择器,以不区分大小写的方式查找以文本开头的元素?

html - 如何使用XPath 1.0在同一行的节点中获取所有文本

java - 是否可以使用 JAXB 根​​据某些属性值获取 XML 元素?

c# - XPath 显式索引过滤器性能

xslt - 一个大的 xslt 优于更小、更细粒度的 xslt

xslt - 将每个组用于高性能XSLT