edu.ucsb.nceas.metacat

## Class DBTransform

- java.lang.Object
- - edu.ucsb.nceas.metacat.DBTransform

-     public class DBTransform
      extends java.lang.Object

  A Class that transforms XML documents utitlizing XSL style sheets Building a transformer from the .xsl is expensive, so Templates are used as an intermediate construct to allow lightweight construction of Transformers. (Transformers themselves are not thread safe, so can't be reused)

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DBTransform()` construct a DBTransform instance.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `doTransform(javax.xml.transform.stream.StreamSource xml, javax.xml.transform.stream.StreamResult resultOutput, java.lang.String xslSystemId, java.util.Hashtable<java.lang.String,java.lang.String[]> param, java.lang.String qformat, java.lang.String sessionid)` Reads skin's config file if it exists, and populates Transformer paramaters with its contents.
    `static org.w3c.dom.NodeList` | `getPathContent(java.io.File f, java.lang.String path)` gets the content of a tag in a given xml file with the given path
    `protected static javax.xml.transform.Transformer` | `getTransformer(java.lang.String xslSystemId)` The method that manages the Templates Map instances that will be used to build transformers from.
    `static void` | `setForceRebuild(boolean forceBuild)` Set the field of forceRebuild
    `void` | `transformXMLDocument(java.lang.String doc, java.lang.String sourceType, java.lang.String targetType, java.lang.String qformat, java.io.Writer w, java.util.Hashtable<java.lang.String,java.lang.String[]> param, java.lang.String sessionid)` Transform an XML document using the stylesheet reference from the db

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### DBTransform

          public DBTransform()
                      throws java.io.IOException,
                             java.sql.SQLException,
                             java.lang.ClassNotFoundException,
                             edu.ucsb.nceas.utilities.PropertyNotFoundException

      construct a DBTransform instance. Generally, one calls transformXMLDocument() after constructing the instance
      Parameters:
        `conn` - the database connection from which to lookup the public ids
      Throws:
        `java.io.IOException`
        `java.sql.SQLException`
        `java.lang.ClassNotFoundException`
        `edu.ucsb.nceas.utilities.PropertyNotFoundException`

  - ### Method Detail

    - #### getTransformer

          protected static javax.xml.transform.Transformer getTransformer(java.lang.String xslSystemId)
                                                                   throws javax.xml.transform.TransformerConfigurationException

      The method that manages the Templates Map instances that will be used to build transformers from.
      Parameters:
        `xslSystemId` - - the URL for the stylesheet
        `forceRebuild` - - if true, forces reload of the stylesheet from the system, else use the existing one, if there
      Returns:
      Throws:
        `javax.xml.transform.TransformerConfigurationException`

    - #### transformXMLDocument

          public void transformXMLDocument(java.lang.String doc,
                                           java.lang.String sourceType,
                                           java.lang.String targetType,
                                           java.lang.String qformat,
                                           java.io.Writer w,
                                           java.util.Hashtable<java.lang.String,java.lang.String[]> param,
                                           java.lang.String sessionid)

      Transform an XML document using the stylesheet reference from the db
      Parameters:
        `doc` - the document to be transformed
        `sourcetype` - the document type of the source
        `targettype` - the target document type
        `qformat` - the name of the style set to use
        `pw` - the PrintWriter to which output is printed
        `params` - some parameters for eml2 transformation

    - #### doTransform

          protected void doTransform(javax.xml.transform.stream.StreamSource xml,
                                     javax.xml.transform.stream.StreamResult resultOutput,
                                     java.lang.String xslSystemId,
                                     java.util.Hashtable<java.lang.String,java.lang.String[]> param,
                                     java.lang.String qformat,
                                     java.lang.String sessionid)
                              throws edu.ucsb.nceas.utilities.PropertyNotFoundException,
                                     javax.xml.transform.TransformerException

      Reads skin's config file if it exists, and populates Transformer paramaters with its contents. It then adds the parameters passed to it via Hashtable param to the Transformer. It then calls the Transformer.transform method.
      Throws:
        `edu.ucsb.nceas.utilities.PropertyNotFoundException`
        `javax.xml.transform.TransformerException`

    - #### getPathContent

          public static org.w3c.dom.NodeList getPathContent(java.io.File f,
                                                            java.lang.String path)

      gets the content of a tag in a given xml file with the given path
      Parameters:
        `f` - the file to parse
        `path` - the path to get the content from

    - #### setForceRebuild

          public static void setForceRebuild(boolean forceBuild)

      Set the field of forceRebuild
      Parameters:
        `forceRebuild` -

Copyright © 2020 Regents of the University of California. All Rights Reserved.