473,396 Members | 1,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

xslt xpath

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


Jul 20 '05 #1
1 2173
/mapping/to[from/@name='Email']

Bob Foster

"P.Hill" <go******@xmission.com> wrote in message
news:bn**********@terabinaries.xmission.com...
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

Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Bill Sneddon | last post by:
Does anyone on this site have an informed guess as to when the standards XSLT 2.0 and XPATH 2.0 will be publish and how long it will take for the common processor will support them?
6
by: Ramon M. Felciano | last post by:
Helo all -- I'm trying to gain a deeper understand for what type of semi-declarative programming can be done through XML and XPath/XSLT. I'm looking at graph processing problems as a testbed for...
3
by: Justine Hlista | last post by:
I'm using xalan-j_2_6_0 and trying to get an example from Michael Kay's book to work: <xsl:template match="/"> <xsl:variable name="rainbow"> <color>red</color> <color>blue</color>...
4
by: Son KwonNam | last post by:
In XSLT, is this possible to get value from xml using XPath which is in XSLT variable? I mean XPath strings can be dynamic while XSL Transforming. If possible, How?? Because I'm not a...
1
by: Rhino | last post by:
Can anyone point me to a good free XSLT Tutorial online? I looked for some a few months ago and didn't find anything very good. I'm hoping some of the experts here can point me to a good XSLT...
0
by: Jay Allard | last post by:
Hello I posted this in the vb.net group on the 2/25/2004, but didn't get any response. Here's attempt 2. Does anyone know of a more appropriate place to post this? One new piece of...
3
by: Ian Roddis | last post by:
Hello, I want to embed SQL type queries within an XML data record. The XML looks something like this: <DISPLAYPAGE> <FIELD NAME="SERVER" TYPE="DROPDOWN"> <OPTION>1<OPTION> <OPTION>2<OPTION>...
1
by: Sergey Dubinets | last post by:
In effort to prioritize our goals we composed the list of random features each of them may add value to set of XSLT tools offered from Microsoft. 1. XSLTc (Compiler for XSLT...
2
jkmyoung
by: jkmyoung | last post by:
Here's a short list of useful xslt general tricks that aren't taught at w3schools. Attribute Value Template Official W3C explanation and example This is when you want to put dynamic values...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.