xslt xpath

P

P.Hill

I'm using jaxen to pull a few things out of DOM tree and having trouble
specifying an xPath.
/mapping/to/from[@name='Email']
works fine, but
/mapping/to[from@name='Email']
doesn't.

I'm sure it is something obvious.

I try the following xPath:
/mapping/to/from[@name='Email']
on the document (simplified for the problem:
<?xml version="1.0"?>
<!DOCTYPE mapping SYSTEM "mapping.dtd">
<mapping table="Contact" >
<to name="contact" >
<from name="Contact" />
</to>
<to name="email" >
<from name="Email" />
</to>
</mapping>

And I get the expected "from" node (the element with the attribute name="Email")

But of course looking for an Element that has nothing, but the value you are matching
is NOT very useful, so you really want some enclosing structure, in my case the enclosing
"to" element will work just fine.
So toward this end, I try:
/mapping/to[from@name='Email']
on the same DOM document and get the error.
org.jaxen.XPathSyntaxException: Unexpected '@'
at org.jaxen.BaseXPath.<init>(BaseXPath.java:136)
[...]

If
/mapping/to/from[@name='Email']
works fine, why doesn't
/mapping/to[from@name='Email']

Can anyone help?
-Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top