XSLT Insert element only if it doesn't exist
问题 I have a source document: <?xml version="1.0"?> <source> <ItemNotSubstituted/> <ItemToBeSubstituted Id='MatchId' /> </source> And a stylesheet containing content I want to substitute into the source: <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output indent="yes" method="xml" omit-xml-declaration="no" version="1.0"/> <xsl:preserve-space elements="//*"/> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*