001 /** 002 * Implements the Cold Fusion Function xmltransform 003 */ 004 package railo.runtime.functions.xml; 005 006 import org.w3c.dom.Document; 007 import org.w3c.dom.Node; 008 009 import railo.runtime.PageContext; 010 import railo.runtime.exp.PageException; 011 import railo.runtime.exp.XMLException; 012 import railo.runtime.ext.function.Function; 013 import railo.runtime.op.Caster; 014 import railo.runtime.text.xml.XMLUtil; 015 import railo.runtime.type.Array; 016 017 public final class XmlTransform implements Function { 018 public static String call(PageContext pc , Object oXml, String xsl) throws PageException { 019 try { 020 Document doc; 021 if(oXml instanceof String) { 022 doc=XMLUtil.parse(XMLUtil.toInputSource(pc, oXml.toString()), null, false); 023 } 024 else if(oXml instanceof Node) doc=XMLUtil.getDocument((Node)oXml); 025 else throw new XMLException("XML Object is of invalid type, must be a XML String or a XML Object","now it is "+Caster.toClassName(oXml)); 026 027 return XMLUtil.transform(doc,XMLUtil.toInputSource(pc, xsl)); 028 } 029 catch (Exception e) { 030 throw Caster.toPageException(e); 031 } 032 } 033 034 public static String call(PageContext pc , Object oXml, String xsl,Array parameters) throws PageException { 035 // TODO impl. parameters support 036 return call(pc, oXml, xsl); 037 } 038 }