1 16 19 package org.apache.xpath.functions; 20 21 import org.apache.xpath.XPathContext; 22 import org.apache.xpath.objects.XObject; 23 import org.apache.xpath.objects.XString; 24 25 29 public class FuncSubstringBefore extends Function2Args 30 { 31 32 40 public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException  41 { 42 43 String s1 = m_arg0.execute(xctxt).str(); 44 String s2 = m_arg1.execute(xctxt).str(); 45 int index = s1.indexOf(s2); 46 47 return (-1 == index) 48 ? XString.EMPTYSTRING : new XString(s1.substring(0, index)); 49 } 50 } 51 | Popular Tags |