286N/A * reserved comment block 286N/A * DO NOT REMOVE OR ALTER! 286N/A * Copyright 1999-2004 The Apache Software Foundation. 286N/A * Licensed under the Apache License, Version 2.0 (the "License"); 286N/A * you may not use this file except in compliance with the License. 286N/A * You may obtain a copy of the License at 286N/A * Unless required by applicable law or agreed to in writing, software 286N/A * distributed under the License is distributed on an "AS IS" BASIS, 286N/A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 286N/A * See the License for the specific language governing permissions and 286N/A * limitations under the License. 286N/A//J2SE does not support Xalan interpretive 286N/Aimport com.sun.org.apache.xalan.internal.trace.PrintTraceListener; 286N/Aimport com.sun.org.apache.xalan.internal.trace.TraceManager; 286N/Aimport com.sun.org.apache.xalan.internal.transformer.XalanProperties; 286N/A * The main() method handles the Xalan command-line interface. 286N/A * Prints argument options. 286N/A * @param resbundle Resource bundle 286N/A // System.out.println(resbundle.getString("optionE")); //" [-E (Do not expand entity refs)]"); 286N/A // System.out.println(resbundle.getString("optionVALIDATE")); //" [-VALIDATE (Set whether validation occurs. Validation is off by default.)]"); 286N/A // J2SE does not support Xalan interpretive 286N/A System.out.println("\n\t\t\t" + resbundle.getString("xslProc_xalan_options") + "\n"); 286N/A System.out.println(resbundle.getString("optionQC")); //" [-QC (Quiet Pattern Conflicts Warnings)]"); 286N/A // System.out.println(resbundle.getString("optionQ")); //" [-Q (Quiet Mode)]"); // sc 28-Feb-01 commented out 286N/A System.out.println(resbundle.getString("optionTT")); //" [-TT (Trace the templates as they are being called.)]"); 286N/A System.out.println(resbundle.getString("optionTG")); //" [-TG (Trace each generation event.)]"); 286N/A System.out.println(resbundle.getString("optionTS")); //" [-TS (Trace each selection event.)]"); 286N/A System.out.println(resbundle.getString("optionTTC")); //" [-TTC (Trace the template children as they are being processed.)]"); 286N/A System.out.println(resbundle.getString("optionTCLASS")); //" [-TCLASS (TraceListener class for trace extensions.)]"); 286N/A System.out.println(resbundle.getString("optionLINENUMBERS")); //" [-L use line numbers]" 286N/A System.out.println(resbundle.getString("optionINCREMENTAL")); 286N/A System.out.println(resbundle.getString("optionNOOPTIMIMIZE")); 286N/A System.out.println(resbundle.getString("optionRL")); 286N/A * Command line interface to transform an XML document according to 286N/A * the instructions found in an XSL stylesheet. 286N/A * <p>The Process class provides basic functionality for 286N/A * performing transformations from the command line. To see a 286N/A * list of arguments supported, call with zero arguments.</p> 286N/A * <p>To set stylesheet parameters from the command line, use 286N/A * <code>-PARAM name expression</code>. If you want to set the 286N/A * parameter to a string value, simply pass the string value 286N/A * as-is, and it will be interpreted as a string. (Note: if 286N/A * the value has spaces in it, you may need to quote it depending 286N/A * on your shell environment).</p> 286N/A * @param argv Input parameters from command line 286N/A // J2SE does not support Xalan interpretive 286N/A // Runtime.getRuntime().traceMethodCalls(false); // turns Java tracing off 286N/A // Runtime.getRuntime().traceMethodCalls(false); 286N/A // Runtime.getRuntime().traceInstructions(false); 286N/A * The default diagnostic writer... 286N/A // J2SE does not support Xalan interpretive 286N/A String value =
"com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl";
286N/A// "XSL Process was not successful."); 286N/A // J2SE does not support Xalan interpretive 286N/A PrintTraceListener tracer = null; 286N/A // The -XSLTC option has been processed. 286N/A // J2SE does not support Xalan interpretive 286N/A else if ("-TT".equalsIgnoreCase(argv[i])) 286N/A tracer = new PrintTraceListener(diagnosticsWriter); 286N/A tracer.m_traceTemplates = true; 286N/A printInvalidXSLTCOption("-TT"); 286N/A // tfactory.setTraceTemplates(true); 286N/A else if ("-TG".equalsIgnoreCase(argv[i])) 286N/A tracer = new PrintTraceListener(diagnosticsWriter); 286N/A tracer.m_traceGeneration = true; 286N/A printInvalidXSLTCOption("-TG"); 286N/A // tfactory.setTraceSelect(true); 286N/A else if ("-TS".equalsIgnoreCase(argv[i])) 286N/A tracer = new PrintTraceListener(diagnosticsWriter); 286N/A tracer.m_traceSelection = true; 286N/A printInvalidXSLTCOption("-TS"); 286N/A // tfactory.setTraceTemplates(true); 286N/A else if ("-TTC".equalsIgnoreCase(argv[i])) 286N/A tracer = new PrintTraceListener(diagnosticsWriter); 286N/A tracer.m_traceElements = true; 286N/A printInvalidXSLTCOption("-TTC"); 286N/A // tfactory.setTraceTemplateChildren(true); 286N/A // xmlProcessorLiaison.setIndent(indentAmount); 286N/A new Object[]{
"-MEDIA" }));
//"Missing argument for); 286N/A new Object[]{
"-FLAVOR" }));
//"Missing argument for); 286N/A new Object[]{
"-PARAM" }));
//"Missing argument for); 286N/A // xmlProcessorLiaison.setShouldExpandEntityRefs(false); 286N/A /* xmlProcessorLiaison.getParserDescription()+ */ 286N/A // J2SE does not support Xalan interpretive 286N/A else if ("-QC".equalsIgnoreCase(argv[i])) 286N/A quietConflictWarnings = true; 286N/A printInvalidXSLTCOption("-QC"); 286N/A new Object[]{
"-URIResolver" });
//"Missing argument for); 286N/A// "Missing argument for); 286N/A// "Missing argument for); 286N/A // J2SE does not support Xalan interpretive 286N/A else if ("-L".equalsIgnoreCase(argv[i])) 286N/A tfactory.setAttribute(XalanProperties.SOURCE_LOCATION, Boolean.TRUE); 286N/A printInvalidXSLTCOption("-L"); 286N/A else if ("-INCREMENTAL".equalsIgnoreCase(argv[i])) 286N/A java.lang.Boolean.TRUE); 286N/A printInvalidXSLTCOption("-INCREMENTAL"); 286N/A else if ("-NOOPTIMIZE".equalsIgnoreCase(argv[i])) 286N/A // %REVIEW% We should have a generalized syntax for negative 286N/A // switches... and probably should accept the inverse even 286N/A // if it is the default. 286N/A java.lang.Boolean.FALSE); 286N/A printInvalidXSLTCOption("-NOOPTIMIZE"); 286N/A else if ("-RL".equalsIgnoreCase(argv[i])) 286N/A if (i + 1 < argv.length) 286N/A recursionLimit = Integer.parseInt(argv[++i]); 286N/A XSLMessages.createMessage( 286N/A XSLTErrorResources.ER_MISSING_ARG_FOR_OPTION, 286N/A new Object[]{ "-rl" })); //"Missing argument for); 286N/A if (i + 1 < argv.length && argv[i + 1].charAt(0) != '-') 286N/A printInvalidXSLTCOption("-RL"); 286N/A // Generate the translet class and optionally specify the name 286N/A // of the translet class. 286N/A // Specify the destination directory for the translet classes. 286N/A // Specify the jar file name which the translet classes are packaged into. 286N/A // Specify the package name prefix for the generated translet classes. 286N/A // Enable template inlining. 286N/A // Turns on additional debugging message output 286N/A // Create the Transformer from the translet if the translet class is newer 286N/A // than the stylesheet. 286N/A // Print usage instructions if no xml and xsl file is specified in the command line 286N/A // Note that there are usage cases for calling us without a -IN arg 286N/A // The main XSL transformation occurs here! 286N/A // Parse in the xml data into a DOM 286N/A // System.out.println("Calling newTemplates: "+xslFileName); 286N/A // System.out.println("Done calling newTemplates: "+xslFileName); 286N/A // One possible improvement might be to ensure this is 286N/A // a valid URI before setting the systemId, but that 286N/A // might have subtle changes that pre-existing users 286N/A // might notice; we can think about that later -sc r1.46 286N/A // We used to default to incremental mode in this case. 286N/A // We've since decided that since the -INCREMENTAL switch is 286N/A // available, that default is probably not necessary nor 286N/A // necessarily a good idea. 286N/A // J2SE does not support Xalan interpretive 286N/A // This is currently controlled via TransformerFactoryImpl. 286N/A if (!useXSLTC && useSourceLocation) 286N/A stf.setAttribute(XalanProperties.SOURCE_LOCATION, Boolean.TRUE); 286N/A // Did they pass in a stylesheet, or should we get it from the 286N/A // + inFileName + ", media=" 286N/A // Override the output format? 286N/A // J2SE does not support Xalan interpretive 286N/A if (transformer instanceof com.sun.org.apache.xalan.internal.transformer.TransformerImpl) 286N/A com.sun.org.apache.xalan.internal.transformer.TransformerImpl impl = (com.sun.org.apache.xalan.internal.transformer.TransformerImpl)transformer; 286N/A TraceManager tm = impl.getTraceManager(); 286N/A tm.addTraceListener(tracer); 286N/A impl.setQuietConflictWarnings(quietConflictWarnings); 286N/A // This is currently controlled via TransformerFactoryImpl. 286N/A impl.setProperty(XalanProperties.SOURCE_LOCATION, Boolean.TRUE); 286N/A impl.setRecursionLimit(recursionLimit); 286N/A // sc 28-Feb-01 if we re-implement this, please uncomment helpmsg in printArgOptions 286N/A // impl.setDiagnosticsOutput( setQuietMode ? null : diagnosticsWriter ); 286N/A // Parse in the xml data into a DOM 286N/A // Now serialize output to disk with identity transformer 286N/A for (
int i =
0; i <
1; i++)
// Loop for diagnosing bugs with inconsistent behavior 286N/A // System.out.println("Testing the TransformerHandler..."); 286N/A // Use JAXP1.1 ( if possible ) 286N/A // J2SE does not support Xalan interpretive 286N/A stf.setAttribute(com.sun.org.apache.xalan.internal.processor.TransformerFactoryImpl.FEATURE_INCREMENTAL, 286N/A // Use JAXP1.1 ( if possible ) 286N/A // System.out.println("Starting transform"); 286N/A // System.out.println("Done with transform"); 286N/A// "XSL Process was not successful."); 286N/A // close output streams 286N/A // diagnosticsWriter.println(XSLMessages.createMessage(XSLTErrorResources.ER_NOT_SUCCESSFUL, null)); //"XSL Process was not successful."); 286N/A // diagnosticsWriter.close(); 286N/A // diagnosticsWriter.println(resbundle.getString("xsldone")); //"Xalan: done"); 286N/A // diagnosticsWriter.println(""); //"Xalan: done"); 286N/A /** It is _much_ easier to debug under VJ++ if I can set a single breakpoint 286N/A * before this blows itself out of the water... 286N/A * (I keep checking this in, it keeps vanishing. Grr!) 286N/A * Wait for a return key to continue 286N/A * @param resbundle The resource bundle 286N/A * Print a message if an option cannot be used with -XSLTC. 286N/A * @param option The option String 286N/A * Print a message if an option can only be used with -XSLTC. 286N/A * @param option The option String