How create XML from XML using XSL?

前端 未结 3 2002
情书的邮戳
情书的邮戳 2020-12-30 06:17

How create XML from XML using XSL ?

I try like this.. but i not get a result

Test.xml

Alex <
3条回答
  •  温柔的废话
    2020-12-30 07:00

    Just to expand and clarify a bit on what Tomalak posted: the root of an XML document is, in the DOM hierarchy, above the top-level element. It's exceptionally common to see the two confused. Consider this XML document:

    
    
       
    
    
    

    The root of this document has three child nodes: a comment node, an element node, and another comment node. The top-level element is named root, because that's what everyone who creates XML instance documents does in order to perpetuate the confusion between the document root and the top-level element. (Especially if they're still at the point in their XML education where they use "node" when they mean "element.")

    This gets us to one of the reasons that the template that Tomalak describes as "nicer" is nicer. If you extend the identity transform, the only thing that the XSLT will change in your document are the elements that you've built templates for. Every other node in the document is copied unchanged. So if your input document has comments around the top-level element, as in the above example, they won't get stripped out of the output, as they would if you simply implemented a template matching the Address element.

    Of course, if you want your output to exclude comments, that's easily accomplished too; just don't implement the identity transform.

提交回复
热议问题