Ignore:
Timestamp:
2009-05-06T14:54:14+12:00 (15 years ago)
Author:
anna
Message:

added a language parameter so that it can be set in the command line when transform xml source file. References to other language-dependent strings will be resolved to the specified language.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • documentation/trunk/shared/ApplyXSLT.java

    r13885 r19339  
    4646    static public void main(String[] args)
    4747    {
    48     if (args.length < 2) {
    49         System.err.println("Usage: ApplyXSLT <XSLfile> <XMLfile> <GSDLHOME>");
     48    if (args.length < 3) {
     49        System.err.println("Usage: ApplyXSLT <Target_language_code> <XSLfile> <XMLfile>");
    5050        System.exit(1);
    51     }
     51    }   
    5252
    5353    System.setProperty("javax.xml.transform.TransformerFactory",
    5454               "org.apache.xalan.processor.TransformerFactoryImpl");
    55         if (args.length == 3){
    56         System.setProperty("GSDLHOME",args[2]);
     55    if (args.length == 4){
     56        System.setProperty("GSDLHOME",args[3]);
    5757    }
    5858
     
    6161        t_factory = org.apache.xalan.processor.TransformerFactoryImpl.newInstance();
    6262    }
    63     catch (Exception ex) {
     63    catch (Exception ex) {   
    6464        System.err.println("XMLTransformer() exception " + ex.getMessage());
    6565        System.exit(1);
    6666    }
    6767
    68     String stylesheet = args[0];
    69     String xml_in = args[1];
     68    String lang = args[0];
     69    String stylesheet = args[1];
     70    String xml_in = args[2];
    7071    try {
    7172        // Use the TransformerFactory to process the stylesheet Source and generate a Transformer
     
    7576        StreamSource input = (xml_in.equals("-") ? new StreamSource(System.in) : new StreamSource(xml_in));
    7677        OutputStreamWriter output = new OutputStreamWriter(System.out, "UTF-8");
     78
     79        transformer.setParameter("lang", lang);
    7780        transformer.transform(input, new StreamResult(output));
    7881    }
Note: See TracChangeset for help on using the changeset viewer.