Project

General

Profile

« Previous | Next » 

Revision 1664

Added by Jing Tao over 21 years ago

Add the code to handle parameter for style sheet.

View differences:

src/edu/ucsb/nceas/metacat/DBTransform.java
32 32
import java.net.URL;
33 33
import java.net.MalformedURLException;
34 34
import java.sql.*;
35
import java.util.Hashtable;
35 36
import java.util.Stack;
36 37

  
37 38
import javax.xml.transform.TransformerFactory;
......
104 105
   * @param targettype the target document type
105 106
   * @param qformat the name of the style set to use
106 107
   * @param pw the PrintWriter to which output is printed
108
   * @param params some parameters for eml2 transformation
107 109
   */
108 110
  public void transformXMLDocument(String doc, String sourceType, 
109
                String targetType, String qformat, PrintWriter pw) {
111
                                   String targetType, String qformat, 
112
                                   PrintWriter pw, Hashtable param) 
113
 {
110 114
    
111 115
    // Look up the stylesheet for this type combination
112 116
    String xslSystemId = getStyleSystemId(qformat, sourceType, targetType);
......
119 123
                                  new StreamSource(xslSystemId));
120 124
        transformer.setParameter("qformat", qformat);
121 125
        MetaCatUtil.debugMessage("qformat: "+qformat, 30);
126
        // Set up parameter for eml2 transformation
127
        if ( param != null)
128
        {
129
           // pass docid
130
           String docid=((String[])param.get("docid"))[0];
131
           if (docid != null && !docid.trim().equals(""))
132
           {
133
             transformer.setParameter("docid", docid);
134
           }
135
           System.out.print("docid: "+docid);
136
           // pass displaymodule
137
           if (param.get("displaymodule") != null)
138
           {
139
             String displayModule=((String[])param.get("displaymodule"))[0];
140
             System.out.print("displayModule1: "+displayModule);
141
             if (displayModule != null && !displayModule.trim().equals(""))
142
             {
143
               System.out.print("displayModule2: "+displayModule);
144
               transformer.setParameter("displaymodule", displayModule);
145
             }
146
             System.out.print("displayModule3: "+displayModule);
147
           }
148
           // pass entitytype
149
           if (param.get("entitytype") != null)
150
           {
151
             String entityType=((String[])param.get("entitytype"))[0];
152
             if (entityType != null && !entityType.trim().equals(""))
153
             {
154
               transformer.setParameter("entitytype", entityType);
155
             }
156
             System.out.print("entityType: "+entityType);
157
           }
158
           // pass entityindex
159
           if (param.get("entityindex") != null)
160
           {
161
             String entityIndex=((String[])param.get("entityindex"))[0];
162
             if (entityIndex != null && !entityIndex.trim().equals(""))
163
             {
164
               transformer.setParameter("entityindex", entityIndex);
165
             }
166
           }
167
            // pass physicalindex
168
           if (param.get("physicalindex") != null)
169
           {
170
             String physicalIndex=((String[])param.get("physicalindex"))[0];
171
             if (physicalIndex != null && !physicalIndex.trim().equals(""))
172
             {
173
               transformer.setParameter("physicalindex", physicalIndex);
174
             }
175
           }
176
            // pass distributionindex
177
           if (param.get("distributionindex") != null)
178
           {
179
             String distributionIndex=((String[])param.get("distributionindex"))[0];
180
             if (distributionIndex != null && !distributionIndex.trim().equals(""))
181
             {
182
               transformer.setParameter("distributionindex", distributionIndex);
183
             }
184
           }
185
            // pass attributeindex
186
           if (param.get("attributeindex") != null)
187
           {
188
             String attributeIndex=((String[])param.get("attributeindex"))[0];
189
             if (attributeIndex != null && !attributeIndex.trim().equals(""))
190
             {
191
               transformer.setParameter("attributeindex", attributeIndex);
192
             }
193
           }
194
        }
122 195
        transformer.transform(new StreamSource(new StringReader(doc)), 
123 196
                              new StreamResult(pw));
124 197
      } catch (Exception e) {
......
421 494
                                   "-//NCEAS//eml-dataset//EN", 
422 495
                                   "-//W3C//HTML//EN", 
423 496
                                   "knb",
424
                                   new PrintWriter(System.out));
497
                                   new PrintWriter(System.out), null);
425 498

  
426 499
        } catch (Exception e) {
427 500
          System.err.println("EXCEPTION HANDLING REQUIRED");

Also available in: Unified diff