Peter,

Thanks for the bug report.  There's actually no problem with the plumbing
of the XPathUtil class itself.  It's correctly establishing the context
and passes it to our XPath engine.  The problem was just that this XPath
engine wasn't resolving namespaces correctly.

I've fixed the problem by adjusting the matching logic to work against
prefixes, not namespaces.  I've also made error checking more aggressive;
a variable that doesn't match with a value now fails immediately during
resolution.

I've checked in changes to the CVS archive that should fix your problem.

Best,

-- 
Shawn Bayern
Author, "JSP Standard Tag Library"  http://www.jstlbook.com
(coming this summer from Manning Publications)

On Tue, 19 Mar 2002, peter lin wrote:

> 
> reading over my last paragraph, it's not clear what I meant, so here's a
> second attempt. The current 3-19 nightly of XPathUtil.valueOf is below:
> 
>     public String valueOf(Node n, String xpath) throws SAXPathException
> {
>       staticInit();
>         XPath xp = new XPath(xpath);
>         return xp.valueOf(getLocalContext(n));
>     }
> 
> when it calls return, it the result of getLocalContext(node) to
> XPath.valueOf(). when I output that result, I get zero length string.
> the source for getLocalContext(node) is below.
> 
>     private Context getLocalContext(Node n) {
>       // set up instance-specific contexts
>         VariableContext vc = new JstlVariableContext();
>         ContextSupport cs = new ContextSupport(nc, fc, vc, dn);
>         Context c = new Context(cs);
>         List l = new ArrayList(1);
>         l.add(n);
>         c.setNodeSet(l);
>       return c;
>     }
> 
> an instance of JstlVariableContext is passed to the constructor of
> ContextSupport, but I don't see where
> JstlVariableContext.getVariableValue() is called. Within
> getLocalContext, should it check to make sure context was created
> correctly when it does Context c = new Context(cs)?
> 
> when I output the result of the hsr.getHeader(localName), it never
> reaches that chunk of code in getVariableValue().
> 
>           else if (namespace.equals(HEADER_NS_URL)) {
>               HttpServletRequest hsr =
>                   (HttpServletRequest) pageContext.getRequest();
>               return hsr.getHeader(localName);
> 
> thanks.
> 
> peter lin
> 
> 
> 
> peter lin
> 
> 
> > Should valueOf(node,string) check the result of
> > xp.valueOf(getLocalContext(n)) and call getLocalContext?  I'm don't
> > completely understand XPathUtil.  Any tips are greatly appreciated.
> > 
> > peter lin
> > 
> > --
> > To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
> 
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
> 


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to