I have a folder with HTML files which look more or less like this:

```
<div id="d10e3019" class="content">
   <h1>header</h1>
   <div class="adv">
      <div class="warn">
         <img width="60px" height="20px" src="img/warn.png" alt="WARNING"></img>
         <p class="cause">gfgfg!</p>
         <p>⇒  Thgfh</p>
         <p class="step">⇔ 
            <span class="emphasis">hgfh
         </p>
      </div>
   </div>
</div>

```

They all have `<div id="someId" class="content">` as root element and then just various HTML markup.

I need to change all of the `src` attributes in the `img` tags of each document to look like this:

```
<img width="60px" height="20px" src="http://server.com/{$nameOfTheCurtentFolder}/img/warn.png" alt="WARNING"></img>

```

and wrap the new output in another `div` with a new child element. The rest of the document needs to be exactly the same.

I tried this stylesheet, but with this stylesheet only the text nodes get written in the output document (while generating the new `div` element works):

```
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version='2.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xmlns:xs='http://www.w3.org/2001/XMLSchema' xmlns:fn='http://www.w3.org/2005/xpath-functions' exclude-result-prefixes='xsl xs fn' xmlns:h="http://java.sun.com/jsf/html">
    <xsl:output method="xml" encoding="utf-8"/>
    <xsl:strip-space elements="*"/>

    <xsl:param name="files" select="collection('./output?select=*.html')"/>

    <xsl:template match="/">
        <xsl:for-each select="$files">
            <xsl:variable name="fileName" select="tokenize(base-uri(), '/')[last()]"/>
            <xsl:result-document method="xhtml" href="new/{$fileName}">
                <div>
                    <h:selectBooleanCheckbox value="pubs"/>
                    <xsl:copy>
                        <xsl:apply-templates select="@* | node()"/>
                    </xsl:copy>
                </div>
            </xsl:result-document>
        </xsl:for-each>
    </xsl:template>
    <xsl:template match="@src">
        <xsl:variable name="nameOfTheCurtentFolder" select="tokenize(base-uri(), '/')[last()-2]"/>
        <xsl:text>http://server.com/</xsl:text>
        <xsl:value-of select="$nameOfTheCurtentFolder"/>
        <xsl:text>/output/</xsl:text>
        <xsl:value-of select="."/>
    </xsl:template>
</xsl:stylesheet>

```

The output looks like this:

```
              <div>
                 <h:selectBooleanCheckbox value="pubs"/>
                  headergfgfg!⇒  Thgfhhgfh
              </div>

```

This is a follow-up to my earlier question, [Change attribute value without creating new output document?](https://stackoverflow.com/questions/34779464/change-attribute-value-without-creating-new-output-document)