Changeset 13473
- Timestamp:
- 2006-12-11T09:43:52+13:00 (17 years ago)
- Location:
- trunk/gsdl
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/java/org/nzdl/gsdl/ApplyXSLT.java
r13470 r13473 260 260 261 261 private void translate(String xml_file, String xsl_file, String output_file)throws IOException,TransformerException, TransformerConfigurationException, FileNotFoundException, IOException{ 262 if (output_file.equals("")) output_file = xml_file + ".out";263 TransformerFactory tFactory = TransformerFactory.newInstance();262 263 TransformerFactory tFactory = TransformerFactory.newInstance(); 264 264 Transformer transformer = tFactory.newTransformer(new StreamSource(xsl_file)); 265 transformer.transform(new StreamSource(new File(xml_file)), new StreamResult(new FileOutputStream(output_file))); 266 System.out.println("done"); 267 } 265 266 OutputStreamWriter output = null; 267 if (output_file.equals("")) { 268 output = new OutputStreamWriter(System.out, "UTF-8"); 269 } 270 else{ 271 output = new OutputStreamWriter(new FileOutputStream(output_file), "UTF-8"); 272 } 273 274 transformer.transform(new StreamSource(new File(xml_file)),new StreamResult(output)); 275 276 } 277 278 static public String replaceAll(String source_string, String match_regexp, String replace_string) 279 { 280 return source_string.replaceAll(match_regexp, replace_string); 281 } 282 268 283 269 284 public static void main(String[] args) … … 327 342 else if(!xml_file.equals("") && !xsl_file.equals("")){ 328 343 core = new ApplyXSLT(); 329 System.out.println("hree");330 344 try { 331 345 core.translate(xml_file,xsl_file,output_file); … … 352 366 System.out.println("\t-t spacifies the xsl file"); 353 367 System.out.println("\t-m specifies the mapping file (for MARCXMLPlugout.pm only)"); 354 System.out.println("\t-o specifies the translation output file name (if this option is absent, the name of the xml file plus .out is used)");368 System.out.println("\t-o specifies the output file name (output to screen if this option is absent)"); 355 369 System.exit(-1); 356 370 }
Note:
See TracChangeset
for help on using the changeset viewer.