1 16 18 package com.sun.org.apache.xpath.internal.jaxp; 19 20 import javax.xml.transform.TransformerException ; 21 import javax.xml.xpath.XPathVariableResolver ; 22 23 import com.sun.org.apache.xml.internal.utils.QName; 24 import com.sun.org.apache.xpath.internal.VariableStack; 25 import com.sun.org.apache.xpath.internal.XPathContext; 26 import com.sun.org.apache.xpath.internal.objects.XObject; 27 28 import com.sun.org.apache.xpath.internal.res.XPATHErrorResources; 29 import com.sun.org.apache.xalan.internal.res.XSLMessages; 30 31 32 38 public class JAXPVariableStack extends VariableStack { 39 40 private final XPathVariableResolver resolver; 41 42 public JAXPVariableStack(XPathVariableResolver resolver) { 43 this.resolver = resolver; 44 } 45 46 public XObject getVariableOrParam(XPathContext xctxt, QName qname) 47 throws TransformerException ,IllegalArgumentException { 48 if ( qname == null ) { 49 String fmsg = XSLMessages.createXPATHMessage( 52 XPATHErrorResources.ER_ARG_CANNOT_BE_NULL, 53 new Object [] {"Variable qname"} ); 54 throw new IllegalArgumentException ( fmsg ); 55 } 56 javax.xml.namespace.QName name = 57 new javax.xml.namespace.QName ( 58 qname.getNamespace(), 59 qname.getLocalPart()); 60 Object varValue = resolver.resolveVariable( name ); 61 if ( varValue == null ) { 62 String fmsg = XSLMessages.createXPATHMessage( 63 XPATHErrorResources.ER_RESOLVE_VARIABLE_RETURNS_NULL, 64 new Object [] { name.toString()} ); 65 throw new TransformerException ( fmsg ); 66 } 67 return XObject.create( varValue, xctxt ); 68 } 69 70 } 71 | Popular Tags |