XSL xsl:template match=“/”

前端 未结 3 979
小鲜肉
小鲜肉 2020-11-27 09:50

I am just learning XML and how to use XSL files. In an XSL file I found the following term:

xsl:template match=\"/\"

What does this stand f

3条回答
  •  盖世英雄少女心
    2020-11-27 10:16

    It's worth noting, since it's confusing for people new to XML, that the root (or document node) of an XML document is not the top-level element. It's the parent of the top-level element. This is confusing because it doesn't seem like the top-level element can have a parent. Isn't it the top level?

    But look at this, a well-formed XML document:

    
    
    
    

    The root of this document has three children: a processing instruction, a comment, and an element.

    So, for example, if you wanted to write a transform that got rid of that comment, but left in any comments appearing anywhere else in the document, you'd add this to the identity transform:

    
    

    Even simpler (and more commonly useful), here's an XPath pattern that matches the document's top-level element irrespective of its name: /*.

提交回复
热议问题