title: Generating SQL using XML and XSLT
body: <p>I have an XML definition that contains an element with child elements. For example:</p>
  
  <pre><code>&lt;a&gt;
   &lt;b&gt;
    &lt;c&gt;C&lt;/c&gt;
    &lt;d&gt;D&lt;/d&gt;
   &lt;/b&gt;
  &lt;/a&gt;
  </code></pre>
  
  <p>I have an XSLT with an output of text. For example:</p>
  
  <pre><code>&lt;xsl...&gt;
    &lt;xsl:output method="text" indent="yes"/&gt;
    &lt;xsl:template match="/"&gt;
      &lt;xsl:copy-of select="/a/b" /&gt;
    ...
  </code></pre>
  
  <p>I want to copy the entire b element and its children into a whitespace-removed string so that I can generate a SQL query. For example:</p>
  
  <pre><code>select * from some-table where xml = '&lt;b&gt;&lt;c&gt;C&lt;/c&gt;&lt;d&gt;D&lt;/d&gt;&lt;/b&gt;'
  </code></pre>
  
  <p>At the moment copy-of is finding the b element but dropping off all element and attribute information leaving only the text content within each. I think this might be to do with the output type.</p>
  
  <p>Any ideas?</p>