How To Copy All Nodes And Change The Value Of Certain Nodes


Have you ever wanted to copy an XML document, but change certain node data during the copy?




<xsl:stylesheet version="1.0" xmlns:xsl="" exclude-result-prefixes="xsl">
  <xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>
  <!-- copy your input verbatim -->
  <xsl:template match="node() | @*">
      <xsl:apply-templates select="node() | @*" />

  <!-- Now copy book id now appending the prefix to the data -->
  <xsl:template match="/Books/Book/BookID">
    <BookID>SomeValue-<xsl:apply-templates select="@*|node()"/></BookID>





There are no notes on this topic.