Project

General

Profile

« Previous | Next » 

Revision 7859

clean up DBTransform in preparation for "view" service. https://projects.ecoinformatics.org/ecoinfo/issues/6019

View differences:

src/edu/ucsb/nceas/metacat/DBQuery.java
2364 2364
                //htmlDoc.append(((DocumentImpl)docImplList.elementAt(i)).getRev());
2365 2365
                htmlDoc.append("</h2>");
2366 2366
                //do the actual transform
2367
                StringWriter docString = new StringWriter();
2367
                Writer docString = new StringWriter();
2368 2368
                xmlToHtml.transformXMLDocument(
2369 2369
                		((DocumentImpl) docImplList.elementAt(i)).toString(), 
2370 2370
                		((DocumentImpl) docImplList.elementAt(i)).getDoctype(), //"-//NCEAS//eml-generic//EN",
src/edu/ucsb/nceas/metacat/DBTransform.java
33 33
import java.io.IOException;
34 34
import java.io.OutputStreamWriter;
35 35
import java.io.StringReader;
36
import java.io.StringWriter;
37 36
import java.io.Writer;
38 37
import java.sql.SQLException;
39 38
import java.util.Enumeration;
......
66 65
 */
67 66
public class DBTransform {
68 67

  
69
  // private Connection	conn = null;
70
  // private MetacatUtil   util = null;
68

  
71 69
  private String 	configDir = null;
72 70
  private String	defaultStyle = null;
73 71
  private Logger logMetacat = Logger.getLogger(DBTransform.class);
......
143 141
      }
144 142
    
145 143
  }
146
  
147
  /**
148
   * Transform an XML document to StringWriter using the stylesheet reference
149
   * from the db
150
   * @param doc the document to be transformed
151
   * @param sourceType the document type of the source
152
   * @param targetType the target document type
153
   * @param qFormat the name of the style set to use
154
   * @param pw the StringWriter to which output will be stored
155
   */
156
  public void transformXMLDocument(String doc, String sourceType,
157
                String targetType, String qFormat, StringWriter pw,
158
                Hashtable<String, String[]> param, String sessionid)
159
  {
160 144

  
161
    // Look up the stylesheet for this type combination
162
    String xslSystemId = getStyleSystemId(qFormat, sourceType, targetType);
163
    if (xslSystemId != null)
164
    {
165
      // Create a stylesheet from the system id that was found
166
      try
167
      {
168
        doc = removeDOCTYPE(doc);
169
        StringReader xml = new StringReader(doc);
170
        StreamResult result = new StreamResult(pw);
171
        doTransform(xml, result, xslSystemId, param, qFormat, sessionid);
172
      }
173
      catch (Exception e)
174
      {
175
        logMetacat.error("DBTransform.transformXMLDocument - " + xslSystemId + ": Error transforming document in " +
176
                   "DBTransform.transformXMLDocument: " +
177
                   e.getMessage());
178 145

  
179
      }
180
    }
181
    else
182
    {
183
      // No stylesheet registered form this document type, so just return the
184
      // XML stream we were passed
185
      pw.write(doc);
186
    }
187
  }
188

  
189

  
190 146
  /**
191 147
   * Reads skin's config file if it exists, and populates Transformer paramaters
192 148
   * with its contents.

Also available in: Unified diff