如何选择具有唯一ID的特定节点并将整个节点作为xml返回. xmllibrarybook id='1'titlefirstTitle/titleauthorfirstAuthor/author/bookbook id='2'titlesecondTitle/titleauthorsecondAuthor/author/bookbook id='3'titlethirdTitle/tit
<xml> <library> <book id='1'> <title>firstTitle</title> <author>firstAuthor</author> </book> <book id='2'> <title>secondTitle</title> <author>secondAuthor</author> </book> <book id='3'> <title>thirdTitle</title> <author>thirdAuthor</author> </book> </library> </xml>
在这种情况下,我想返回id =’3’的书,所以它看起来像这样:
<book id='3'> <title>thirdTitle</title> <author>thirdAuthor</author> </book>这个XSLT 1.0样式表……
<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes"/> <xsl:template match="/"> <xsl:apply-templates select="*/*/book[@id='3']" /> </xsl:template> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()" /> </xsl:copy> </xsl:template> </xsl:stylesheet>
…将您的样本输入文档转换为所述的样本输出文档