Package edu.ucsb.nceas.metacat
Class DBTransform
java.lang.Object
edu.ucsb.nceas.metacat.DBTransform
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
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
doTransform
(StreamSource xml, StreamResult resultOutput, Transformer transformer, Hashtable<String, String[]> param, String qformat, String sessionid) Reads skin's config file if it exists, and populates Transformer paramaters with its contents.static NodeList
getPathContent
(File f, String path) gets the content of a tag in a given xml file with the given pathprotected static Transformer
getTransformer
(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 forceRebuildvoid
transformXMLDocument
(String doc, String sourceType, String targetType, String qformat, Writer w, Hashtable<String, String[]> param, String sessionid) Transform an XML document using the stylesheet reference from the db
-
Constructor Details
-
DBTransform
public DBTransform() throws IOException, SQLException, ClassNotFoundException, edu.ucsb.nceas.utilities.PropertyNotFoundExceptionconstruct a DBTransform instance. Generally, one calls transformXMLDocument() after constructing the instance- Parameters:
conn
- the database connection from which to lookup the public ids- Throws:
IOException
SQLException
ClassNotFoundException
edu.ucsb.nceas.utilities.PropertyNotFoundException
-
-
Method Details
-
getTransformer
protected static Transformer getTransformer(String xslSystemId) throws TransformerConfigurationException The method that manages the Templates Map instances that will be used to build transformers from.- Parameters:
xslSystemId
- - the URL for the stylesheetforceRebuild
- - if true, forces reload of the stylesheet from the system, else use the existing one, if there- Returns:
- Throws:
TransformerConfigurationException
-
transformXMLDocument
public void transformXMLDocument(String doc, String sourceType, String targetType, String qformat, Writer w, Hashtable<String, String[]> param, String sessionid) Transform an XML document using the stylesheet reference from the db- Parameters:
doc
- the document to be transformedsourcetype
- the document type of the sourcetargettype
- the target document typeqformat
- the name of the style set to usepw
- the PrintWriter to which output is printedparams
- some parameters for eml2 transformation
-
doTransform
protected void doTransform(StreamSource xml, StreamResult resultOutput, Transformer transformer, Hashtable<String, String[]> param, String qformat, String sessionid) throws edu.ucsb.nceas.utilities.PropertyNotFoundException, TransformerExceptionReads 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
TransformerException
-
getPathContent
gets the content of a tag in a given xml file with the given path- Parameters:
f
- the file to parsepath
- the path to get the content from
-
setForceRebuild
public static void setForceRebuild(boolean forceBuild) Set the field of forceRebuild- Parameters:
forceRebuild
-
-