PDA

View Full Version : Relative XPath with DataPointer


mericson
10-16-2004, 06:39 AM
I was hoping that I could use setXPath on a DataPointer to do a relative XPath. Unfortunately it looks like it only works with an absolute XPath. Somewhere in the forums I noticed this was considered a bug.

It is very inconvenient and breaks my modularity to have to set the XPath via aboslute path. If I can do relative paths I can process a certain kind of element entirely independent of its outer context.

Yes, it is possible to do a relative XPathQuery, but that returns data I want to move the pointer.

ch_bowen
10-17-2004, 12:30 PM
someView.datapath.setPointer(anotherView.datapath. p)

Hope this helps,
Chris

mericson
10-17-2004, 05:45 PM
I'm not sure that helps, I don't have a datapointer but have a xpath expression I want to apply. If you can show me some code that does the following then I'm set.

I have an existing datapath pointing to some element (or elements) within a dataset. I have no idea where in the dataset, or which dataset for that matter.

I do know that the datapath is supposed to be pointing to a particular kind of element. I also know I want to get to a particular child of that element. So, I want to take that datapath, and navigate based on a new xpath expression.

xpathQuery doesn't do it because that just returns data. I don't think setXPath does what I want either.

In a sense what I'm looking for is something like the 'select' functions, but one that is 'selectXPath'

ch_bowen
10-18-2004, 05:47 PM
I'm not sure if I understand you correctly or not but you did mention this in your last post:

"I have an existing datapath pointing to some element (or elements) within a dataset. I have no idea where in the dataset, or which dataset for that matter.

I do know that the datapath is supposed to be pointing to a particular kind of element. I also know I want to get to a particular child of that element. So, I want to take that datapath, and navigate based on a new xpath expression."

So, if you have the datapath you can get a datanode from by doing an xpathQuery. From there, you can navigate by calling mydatapath.setPointer(LzDataNode) which will move the pointer.

var datanode = mydatapath.xpathQuery('mychild/child');

mydatapath.setPointer(datanode);

In this case, 'mydatapath' should now be pointing at the 'child' element. I don't know if this helps or not. Maybe I need to see a more concrete example of what you are trying to do.


At any case, Antun has an example of it here...whether this will help you or not I'm not sure.

http://www.laszlosystems.com/developers/community/forums/showthread.php?threadid=612&highlight=setting+datapath