title: Save data from XSLT generated from to an XML file
body: <p>i have a trouble while trying to save some data to XML using XSLT.
  So the problem is that everything seems to be ok, no exceptions are thrown, log files are also clean, but I can't see any changes in XML file. And I can't
  Here is my code for saving output to file</p>
  
  <pre><code>    Transformer transformer = XslTemplatesPool.getTransformer(SAVE_ITEM, realPath);
      setCategoryAndSubcateory(transformer, request);
  
      String name = request.getParameter(NAME);
      /*retrieving some more parameters*/
      String price = request.getParameter(PRICE);
  
      transformer.setParameter(NAME, name);
      /*...*/
      transformer.setParameter(XML_PATH, "E:/xslt/WebContent/xml/shop.xml");
  
      if (price == null) {
          price = "";
      }
      transformer.setParameter(PRICE, price);
      if (notInStock == null) {
          notInStock = "";
      }
      /*
       * out is an instance of PrintWriter
       * PrintWriter out = httpServletResponse.getWriter()
       */
      transformer.setParameter(NOT_IN_STOCK, notInStock);
      executeWrite(out, readWriteLock, transformer);
  
  
      protected void executeWrite(PrintWriter out, ReadWriteLock readWriteLock, Transformer transformer) throws HandledException {
  
      Source xmlSource = new StreamSource("E:/xslt/WebContent/xml/shop.xml");
      StreamResult result = new StreamResult(out);
      Lock writeLock = readWriteLock.writeLock();
      writeLock.lock();
  
      try {
          transformer.transform(xmlSource, result);
      } catch (TransformerException e) {
          ExceptionHandler.logAndThrow(e, logger);
      } finally {
          writeLock.unlock();
      }
  }
  </code></pre>
  
  <p>From XSLT-generated form addItem (every peace of infomation I need comes nice and smooth at this stage) I retreve some data and try to add it to an xml file using template saveItem</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:xs="http://www.example.org/products"
  xmlns:redirect="http://xml.apache.org/xalan/redirect"
  extension-element-prefixes="redirect"
  xmlns:validation="xalan://com.xslt.util.Validator"
  exclude-result-prefixes="validation redirect"&gt;
  
  &lt;xsl:import href="addItem.xsl" /&gt;
  &lt;xsl:import href="productsList.xsl" /&gt;
  
  &lt;xsl:param name="categoryName" /&gt;
  &lt;xsl:param name="subcategoryName" /&gt;
  &lt;xsl:param name="name" /&gt;
  &lt;xsl:param name="producer" /&gt;
  &lt;xsl:param name="model" /&gt;
  &lt;xsl:param name="date-of-issue" /&gt;
  &lt;xsl:param name="color" /&gt;
  &lt;xsl:param name="not-in-stock" /&gt;
  &lt;xsl:param name="price" /&gt;
  &lt;xsl:param name="xmlPath"/&gt;
  &lt;xsl:param name="isValid" select="validation:validate($name, $producer, $model, $date-of-issue, $color, $price, $not-in-stock)" /&gt;
  &lt;xsl:param name="nameError" select="validation:getNameError()" /&gt;
  &lt;xsl:param name="producerError" select="validation:getProducerError()" /&gt;
  &lt;xsl:param name="modelError" select="validation:getModelError()" /&gt;
  &lt;xsl:param name="dateError" select="validation:getDateError()" /&gt;
  &lt;xsl:param name="priceError" select="validation:getPriceError()" /&gt;
  &lt;xsl:param name="colorError" select="validation:getColorError()" /&gt;
  
  &lt;xsl:template match="/" priority="2"&gt;
      &lt;xsl:choose&gt;
          &lt;xsl:when test="not($isValid)"&gt;
              &lt;xsl:call-template name="addItem"&gt;
                  &lt;xsl:with-param name="nameError" select="$nameError" /&gt;
                  &lt;xsl:with-param name="producerError" select="$producerError" /&gt;
                  &lt;xsl:with-param name="modelError" select="$modelError" /&gt;
                  &lt;xsl:with-param name="dateError" select="$dateError" /&gt;
                  &lt;xsl:with-param name="priceError" select="$priceError" /&gt;
                  &lt;xsl:with-param name="colorError" select="$colorError" /&gt;
                  &lt;xsl:with-param name="not-in-stock" select="$not-in-stock" /&gt;
              &lt;/xsl:call-template&gt;
          &lt;/xsl:when&gt;
          &lt;xsl:otherwise&gt;
              &lt;redirect:write select="$xmlPath"&gt;
                  &lt;xsl:call-template name="saveItem" /&gt;
              &lt;/redirect:write&gt;
              &lt;xsl:call-template name="returnToProducts" /&gt;
          &lt;/xsl:otherwise&gt;
      &lt;/xsl:choose&gt;
  &lt;/xsl:template&gt;
  
  &lt;xsl:template name="saveItem" match="@*|node()" priority="2"&gt;
      &lt;xsl:copy&gt;
          &lt;xsl:apply-templates select="@*|node()" /&gt;
      &lt;/xsl:copy&gt;
  &lt;/xsl:template&gt;
  
  &lt;xsl:template match="/xs:shop/xs:category[@name=$categoryName]/xs:subcategory[@name=$subcategoryName]"&gt;
      &lt;xsl:copy&gt;
          &lt;xsl:apply-templates select="@*|node()" /&gt;
          &lt;xsl:element name="xs:product"&gt;
              &lt;xsl:attribute name="name"&gt;
                  &lt;xsl:value-of select="$name" /&gt;
              &lt;/xsl:attribute&gt;
              &lt;xsl:attribute name="producer"&gt;
                  &lt;xsl:value-of select="$producer" /&gt;
              &lt;/xsl:attribute&gt;
              &lt;xsl:attribute name="model"&gt;
                  &lt;xsl:value-of select="$model" /&gt;
              &lt;/xsl:attribute&gt;
              &lt;xsl:element name="xs:date-of-issue"&gt;
                  &lt;xsl:value-of select="$date-of-issue" /&gt;
              &lt;/xsl:element&gt;
              &lt;xsl:element name="xs:color"&gt;
                  &lt;xsl:value-of select="$color" /&gt;
              &lt;/xsl:element&gt;
              &lt;xsl:choose&gt;
                  &lt;xsl:when test="$not-in-stock"&gt;
                      &lt;xsl:element name="xs:not-in-stock" /&gt;
                  &lt;/xsl:when&gt;
                  &lt;xsl:otherwise&gt;
                      &lt;xsl:element name="xs:price"&gt;
                          &lt;xsl:value-of select="$price" /&gt;
                      &lt;/xsl:element&gt;
                  &lt;/xsl:otherwise&gt;
              &lt;/xsl:choose&gt;
          &lt;/xsl:element&gt;
      &lt;/xsl:copy&gt;
  &lt;/xsl:template&gt;
  
  &lt;xsl:template name="returnToProducts"&gt;
      &lt;html&gt;
          &lt;head&gt;
              &lt;meta http-equiv="refresh" content="0;url=controller.do?command=productsList&amp;amp;categoryName={$categoryName}&amp;amp;subcategoryName={$subcategoryName}" /&gt;
          &lt;/head&gt;
      &lt;/html&gt;
  &lt;/xsl:template&gt;
  
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>example of my XML file</p>
  
  <pre><code>&lt;xs:shop xmlns:xs="http://www.example.org/products" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.example.org/products shop.xsd"&gt;    
  &lt;xs:category name="bicycle"&gt;
      &lt;xs:subcategory name="frame"&gt;
          &lt;xs:product name="Soda FR" producer="NS" model="fr445"&gt;
              &lt;xs:date-of-issue&gt;10-05-2012&lt;/xs:date-of-issue&gt;
              &lt;xs:color&gt;white&lt;/xs:color&gt;
              &lt;xs:price&gt;520$&lt;/xs:price&gt;
          &lt;/xs:product&gt;
          &lt;xs:product name="Nucleon" producer="Nicolai" model="nc428"&gt;
              &lt;xs:date-of-issue&gt;10-05-2012&lt;/xs:date-of-issue&gt;
              &lt;xs:color&gt;dark grey&lt;/xs:color&gt;
              &lt;xs:not-in-stock/&gt;
          &lt;/xs:product&gt;
      &lt;/xs:subcategory&gt;
  &lt;/xs:category&gt;
  &lt;/xs:shop&gt;
  </code></pre>