title: XSLT to replace element value if it starts-with a given prefix but leave the rest of the XML as is
body: <p>I am trying to do a simple "find-replace" in xslt but having trouble getting it to produce the correct output. I tried to follow other examples but unfortunately I haven't done much with XSLT and haven't been able to locate an example which does what I want to do.</p>
  
  <p>I have the following XML:</p>
  
  <pre><code>&lt;metadata&gt;
  &lt;Permissions&gt;site:abcdefg-123456-id1::{azeckoski}h,S,r&lt;/Permissions&gt;
  &lt;Permissions&gt;site:hjklqwe-098765-id2::{person2}h,S,r&lt;/Permissions&gt;
  &lt;Permissions&gt;playlist:5678::{azeckoski}h,S,r&lt;/Permissions&gt;
  &lt;Permissions&gt;playlist:7890::{azeckoski}H,s,r&lt;/Permissions&gt;
  &lt;Permissions&gt;playlist:1234::{person1}H,s,R&lt;/Permissions&gt;
  &lt;/metadata&gt;
  </code></pre>
  
  <p>And the following XSLT:</p>
  
  <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:package="info:srw/extension/13/package-v1.0" &gt;
  &lt;xsl:output omit-xml-declaration="yes" indent="no"/&gt;
   &lt;xsl:template match="node()|@*"&gt;
    &lt;xsl:copy&gt;
     &lt;xsl:apply-templates select="node()|@*"/&gt;
    &lt;/xsl:copy&gt;
   &lt;/xsl:template&gt;
   &lt;xsl:template match="metadata[starts-with(Permissions,'site:abcdefg-123456-id1::')]"&gt;
    &lt;xsl:copy&gt;
     &lt;xsl:text&gt;site:abcdefg-123456-id1::{azeckoski}H,S,R&lt;/xsl:text&gt;
    &lt;/xsl:copy&gt;
   &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>I would like to end up with the following XML:</p>
  
  <pre><code>&lt;metadata&gt;
  &lt;Permissions&gt;site:abcdefg-123456-id1::{azeckoski}H,S,R&lt;/Permissions&gt;
  &lt;Permissions&gt;site:hjklqwe-098765-id2::{person2}h,S,r&lt;/Permissions&gt;
  &lt;Permissions&gt;playlist:5678::{azeckoski}h,S,r&lt;/Permissions&gt;
  &lt;Permissions&gt;playlist:7890::{azeckoski}H,s,r&lt;/Permissions&gt;
  &lt;Permissions&gt;playlist:1234::{person1}H,s,R&lt;/Permissions&gt;
  &lt;/metadata&gt;
  </code></pre>
  
  <p>However I end up with this instead:</p>
  
  <pre><code>&lt;metadata&gt;site:abcdefg-123456-id1::{azeckoski}H,S,R&lt;/metadata&gt;
  </code></pre>
  
  <p>I don't understand why the rest of the XML document is being wiped out. I thought I was using the identity template to keep everything else as it is.</p>