001 /** 002 * Implements the CFML Function xmlparse 003 */ 004 package railo.runtime.functions.xml; 005 006 import org.w3c.dom.Node; 007 import org.xml.sax.InputSource; 008 009 import railo.commons.lang.StringUtil; 010 import railo.runtime.PageContext; 011 import railo.runtime.exp.PageException; 012 import railo.runtime.ext.function.Function; 013 import railo.runtime.op.Caster; 014 import railo.runtime.text.xml.XMLCaster; 015 import railo.runtime.text.xml.XMLUtil; 016 017 public final class XmlParse implements Function { 018 public static Node call(PageContext pc , String string) throws PageException { 019 return call(pc,string,false,null); 020 } 021 public static Node call(PageContext pc , String string, boolean caseSensitive) throws PageException { 022 return call(pc, string, caseSensitive,null); 023 024 } 025 public static Node call(PageContext pc , String strXML, boolean caseSensitive, String strValidator) throws PageException { 026 try { 027 InputSource xml = XMLUtil.toInputSource(pc,strXML.trim()); 028 InputSource validator =StringUtil.isEmpty(strValidator)?null:XMLUtil.toInputSource(pc,strValidator.trim()); 029 return XMLCaster.toXMLStruct(XMLUtil.parse(xml,validator,false),caseSensitive); 030 } 031 catch (Exception e) { 032 throw Caster.toPageException(e); 033 } 034 } 035 }