XSLTEngine.java revision 2
c869993e79c1eafbec61a56bf6cea848fe754c71xy// The MIT License
c869993e79c1eafbec61a56bf6cea848fe754c71xy// Copyright (c) 2004 Evren Sirin
c869993e79c1eafbec61a56bf6cea848fe754c71xy// Permission is hereby granted, free of charge, to any person obtaining a copy
c869993e79c1eafbec61a56bf6cea848fe754c71xy// of this software and associated documentation files (the "Software"), to
c869993e79c1eafbec61a56bf6cea848fe754c71xy// deal in the Software without restriction, including without limitation the
c869993e79c1eafbec61a56bf6cea848fe754c71xy// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
c869993e79c1eafbec61a56bf6cea848fe754c71xy// sell copies of the Software, and to permit persons to whom the Software is
c869993e79c1eafbec61a56bf6cea848fe754c71xy// furnished to do so, subject to the following conditions:
c869993e79c1eafbec61a56bf6cea848fe754c71xy// The above copyright notice and this permission notice shall be included in
c869993e79c1eafbec61a56bf6cea848fe754c71xy// all copies or substantial portions of the Software.
c869993e79c1eafbec61a56bf6cea848fe754c71xy// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
c869993e79c1eafbec61a56bf6cea848fe754c71xy// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
c869993e79c1eafbec61a56bf6cea848fe754c71xy// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
c869993e79c1eafbec61a56bf6cea848fe754c71xy// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
c869993e79c1eafbec61a56bf6cea848fe754c71xy// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
c869993e79c1eafbec61a56bf6cea848fe754c71xy// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
c869993e79c1eafbec61a56bf6cea848fe754c71xy// IN THE SOFTWARE.
c869993e79c1eafbec61a56bf6cea848fe754c71xypublic class XSLTEngine {
c869993e79c1eafbec61a56bf6cea848fe754c71xy final static boolean DEBUG = false;
c869993e79c1eafbec61a56bf6cea848fe754c71xy public static String transform(String input, String xsltStylesheet) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy return transform(input, xsltStylesheet, new ValueMap() );
c869993e79c1eafbec61a56bf6cea848fe754c71xy public static String transform(String input, String xsltStylesheet, ValueMap parameters) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy System.out.println("XSLT " + (xsltStylesheet==null) + " " +
c869993e79c1eafbec61a56bf6cea848fe754c71xy TransformerFactory tFactory = TransformerFactory.newInstance();
c869993e79c1eafbec61a56bf6cea848fe754c71xy for(Iterator i = parameters.getVariables().iterator(); i.hasNext();) {
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl transformer.setParameter( param.getURI().toString(), value );
c869993e79c1eafbec61a56bf6cea848fe754c71xy } catch(Exception e) {
c869993e79c1eafbec61a56bf6cea848fe754c71xy System.out.println("XSLT Engine cannot apply transformation " + e);