You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by "Williams, Trevor" <tw...@netperceptions.com> on 2000/09/06 21:56:52 UTC

XPath/DOM discrepency with &...; encoding?

Forgive me if this has been beaten to death already, or is just plain naive.
I'm trying to use XPath to locate a particular DOM node that has an
attribute containing a double quote.  Here's the abbreviated xml:

<channel>
  <location>
    <group name = "&quot;Test&quot; Group" />
  </location>
</channel>

After building the DOM tree I examine the "group" node and sure enough, the
&quot;s have become "s.  So then I try to locate the node:

Node n = XPathAPI.selectSingleNode(rootNode,
"/channel/location/group[@name=\"" + s + "\"]");

The variable s is a String I've alternately defined as:
	"&quot;Test&quot; Group",
	"\"Test\" Group", and
	"\\\"Test\\\" Group".

My apologies for that last one if you're reading this with Outlook.  None of
them work.  The first one simply doesn't match, and the other two produce
parse exceptions because of the embedded quotation marks.
I've traced the behavior to XPathProcessorImpl.parse(), but after looking
through the source I'm not sure of the correct approach.  Can someone more
intimate with XPath point me in the right direction?  Is this a bug, a
design decision, or a case of insufficient familiarity on my part?

Thanks in advance,
Trevor Williams