gt:         catch (TransformerException exc) {
context: /*******************************************************************************
   * Copyright (c) 2009, 2016 GreenVulcano ESB Open Source Project.
   * All rights reserved.
   *
   * This file is part of GreenVulcano ESB.
   *
   * GreenVulcano ESB is free software: you can redistribute it and/or modify
   * it under the terms of the GNU Lesser General Public License as published by
   * the Free Software Foundation, either version 3 of the License, or
   * (at your option) any later version.
   *
   * GreenVulcano ESB is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   * GNU Lesser General Public License for more details.
   *
   * You should have received a copy of the GNU Lesser General Public License
   * along with GreenVulcano ESB. If not, see <http://www.gnu.org/licenses/>.
   *******************************************************************************/
  package it.greenvulcano.gvesb.j2ee.db.utils;
  
  import it.greenvulcano.util.bin.BinaryUtils;
  import it.greenvulcano.util.txt.DateUtils;
  import it.greenvulcano.util.xpath.XPathDOMBuilder;
  import it.greenvulcano.util.xpath.XPathUtilsException;
  
  import java.io.IOException;
  import java.io.InputStream;
  import java.io.OutputStream;
  import java.io.UnsupportedEncodingException;
  import java.math.BigDecimal;
  import java.sql.Blob;
  import java.sql.Clob;
  import java.sql.ResultSet;
  import java.sql.ResultSetMetaData;
  import java.sql.SQLException;
  import java.sql.Types;
  import java.util.Base64;
  
  import javax.xml.transform.OutputKeys;
  import javax.xml.transform.Transformer;
  import javax.xml.transform.TransformerException;
  import javax.xml.transform.TransformerFactory;
  import javax.xml.transform.dom.DOMSource;
  import javax.xml.transform.stream.StreamResult;
  import javax.xml.transform.stream.StreamSource;
  
  import org.slf4j.Logger;
  import org.w3c.dom.Document;
  
  /**
   * An implementation of the XmlWriter interface, which writes a ResultSet object
   * to an output stream as an XML document
   *
   * @version 3.0.0 Feb 17, 2010
   * @author GreenVulcano Developer Team
   *
   *
   */
  public class XmlWriterImpl implements XmlWriter
  {
      private static final Logger logger          = org.slf4j.LoggerFactory.getLogger(XmlWriterImpl.class);
  
      /**
       * The XPath DOM builder
       */
      private XPathDOMBuilder     xpathDOMBuilder = null;
  
      /**
       * The document
       */
      private Document            document        = null;
  
      /**
       * The DTD
       */
      private String              strPublicDtdID  = "";
  
      /**
       * The system identification
       */
      private String              strSystemID     = "";
  
      /**
       * The structure
       */
      private int                 iStructure      = XmlWriter.METADATA_AND_DATA;
  
      /**
       * If the result set is empty or not
       */
      private boolean             rsEmpty         = true;
  
      /**
       * The number of record read
       */
      private int                 recordCount     = 0;
  
      /**
       * Get the DTD identification
       *
       * @return the identification DTD string
       */
      public String getPublicDtdID()
      {
          return strPublicDtdID;
      }
  
      /**
       * The system identification
       *
       * @return the system identification
       */
      public String getSystemID()
      {
          return strSystemID;
      }
  
      /**
       * get the structure
       *
       * @return the structure
       */
      public int getStructure()
      {
          return iStructure;
      }
  
      /**
       * set the identification DTD
       *
       * @param strPublicDtdID
       *        the DTD identification
       */
      public void setPublicDtdID(String strPublicDtdID)
      {
          this.strPublicDtdID = strPublicDtdID;
      }
  
      /**
       * The system identification
       *
       * @param strSystemID
       *        the system identification
       */
      public void setSystemID(String strSystemID)
      {
          this.strSystemID = strSystemID;
      }
  
      /**
       * set the structure
       *
       * @param iStructure
       *        the structure
       */
      @Override
      public void setStructure(int iStructure)
      {
          this.iStructure = iStructure;
      }
  
      /**
       * Writes the given ResultSet object to the specified java.io.OutputStream
       * as an XML document.
       *
       * @param resultSet
       *        input ResultSet.
       * @param outputStream
       *        output stream.
       * @param enc
       *        encoding used for output stream.
       * @param inputStream
       *        transformation to apply.
       * @throws XmlWriterException
       *         if errors occur.
       */
      @Override
      public void writeXML(ResultSet resultSet, OutputStream outputStream, String enc, InputStream inputStream)
              throws XmlWriterException
      {
          Transformer transformer = null;
  
          try {
              xpathDOMBuilder = new XPathDOMBuilder();
              document = xpathDOMBuilder.createNewDocument();
  
              writeResultSet(resultSet);
  
              if (inputStream == null) {
                  transformer = TransformerFactory.newInstance().newTransformer();
              }
              else {
                  transformer = (TransformerFactory.newInstance()).newTransformer(new StreamSource(inputStream));
              }
  
              transformer.setOutputProperty(OutputKeys.ENCODING, enc);
              DOMSource source = new DOMSource(document);
              transformer.transform(source, new StreamResult(outputStream));
          }
  