1 16 19 package org.apache.xalan.extensions; 20 21 import org.apache.xalan.templates.StylesheetRoot; 22 import org.apache.xpath.ExpressionOwner; 23 import org.apache.xpath.XPathVisitor; 24 import org.apache.xpath.functions.FuncExtFunction; 25 import org.apache.xpath.functions.FuncExtFunctionAvailable; 26 import org.apache.xpath.functions.Function; 27 28 38 public class ExpressionVisitor extends XPathVisitor 39 { 40 private StylesheetRoot m_sroot; 41 42 47 public ExpressionVisitor (StylesheetRoot sroot) 48 { 49 m_sroot = sroot; 50 } 51 52 60 public boolean visitFunction(ExpressionOwner owner, Function func) 61 { 62 if (func instanceof FuncExtFunction) 63 { 64 String namespace = ((FuncExtFunction)func).getNamespace(); 65 m_sroot.getExtensionNamespacesManager().registerExtension(namespace); 66 } 67 else if (func instanceof FuncExtFunctionAvailable) 68 { 69 String arg = ((FuncExtFunctionAvailable)func).getArg0().toString(); 70 if (arg.indexOf(":") > 0) 71 { 72 String prefix = arg.substring(0,arg.indexOf(":")); 73 String namespace = this.m_sroot.getNamespaceForPrefix(prefix); 74 m_sroot.getExtensionNamespacesManager().registerExtension(namespace); 75 } 76 } 77 return true; 78 } 79 80 } 81 | Popular Tags |