/* Utilities that manipulate strings using XSLT. Copyright (c) 2002-2014 The Regents of the University of California. All rights reserved. Permission is hereby granted, without written agreement and without license or royalty fees, to use, copy, modify, and distribute this software and its documentation for any purpose, provided that the above copyright notice and the following two paragraphs appear in all copies of this software. IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. PT_COPYRIGHT_VERSION_2 COPYRIGHTENDKEY */ package ptolemy.util; import java.io.ByteArrayOutputStream; import java.io.FileWriter; import java.io.IOException; import java.io.OutputStream; import java.net.URL; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.ErrorListener; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMResult; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; import org.w3c.dom.Document; import org.xml.sax.InputSource; import org.xml.sax.SAXException; /////////////////////////////////////////////////////////////////// //// XSLTUtilities /** A collection of utilities for manipulating strings using XSLT. These utilities do not depend on any other ptolemy.* packages.

This file uses Saxon, the XSLT and XQuery Processor http://saxon.sourceforge.net.

Between Java 1.4.x and Java 1.5, Xalan was removed from the jar files that are shipped. Since Caltrop uses Saxon anyway, we now use Saxon here as well. @author Christopher Hylands, Haiyang Zheng @version $Id: XSLTUtilities.java 70402 2014-10-23 00:52:20Z cxh $ @since Ptolemy II 2.1 @Pt.ProposedRating Green (eal) Pending Java 1.5 changes @Pt.AcceptedRating Yellow (cxh) */ public class XSLTUtilities { /** Instances of this class cannot be created. */ private XSLTUtilities() { } /////////////////////////////////////////////////////////////////// //// public methods //// /** Apply XSL transforms to an input file and generate an output file. *

Example use: *

     *  java -classpath $PTII ptolemy.util.XSLTUtilities
     *       $PTII/ptolemy/hsif/demo/SwimmingPool/SwimmingPool.xml \
     *       $PTII/ptolemy/hsif/xsl/GlobalVariablePreprocessor.xsl \
     *       exportMoMLDTD \
     *       /tmp/SwimmingPool_1.xml
     * 
* @param args At least three arguments: *