I've run into a problem with using the LzDatapointer setXPath
functionality. I have some XML which looks like this:
<outerElement>
<innerElements>
<innerElement uri="http://foo.bar.com/four"/>
<innerElement uri="http://foo.bar.com/five?boo=baz"/>
</innerElements>
</outterElement>
I have a datapointer which points to the root of a dataset containing
the above XML. I'm trying to use setXPath to set a pointer to one of
the 'innerElement' elements. If I use the following statement:
var adjUri = LzBrowser.xmlEscape("http://foo.bar.com/four");
result =
selectedUserChannel.setXPath("testds:/outerElement/innerElements/[EMAIL
PROTECTED]'"
+ adjUri + "']");
The value of result is 'true', meaning the xpath command found the
element. However, if I do this:
var adjUri = LzBrowser.xmlEscape("http://foo.bar.com/five?boo=baz");
result =
selectedUserChannel.setXPath("testds:/outerElement/innerElements/[EMAIL
PROTECTED]'"
+ adjUri + "']");
The function returns false.
I have some code which is trying to find some elements in my XML based
on a URI value. Sometimes the URI has no query string associated with
it, othertimes it does. Whenever the URI has a query string, I'm unable
to find the element in my dataset, even though the value is there.
Any thoughts on what I might be doing wrong?
Here is a complete program which demostrates the problem:
<canvas debug="true">
<dataset name="testds">
<outerElement>
<innerElements>
<innerElement uri="http://foo.bar.com/one"/>
<innerElement uri="http://foo.bar.com/two"/>
<innerElement
uri="http://foo.bar.com/three?boo=bah&junk=dog"/>
<innerElement uri="http://foo.bar.com/four"/>
<innerElement uri="http://foo.bar.com/five?boo=baz"/>
</innerElements>
</outerElement>
</dataset>
<datapointer name="outerElement" xpath="testds:/outerElement"/>
<view height="600" width="600" bgcolor="gray">
<simplelayout axis="y" spacing="20"/>
<view
datapath="testds:/outerElement/innerElements/innerElement[4]"
width="${parent.width}">
<text name="test" datapath="@uri" width="600" bgcolor="white"/>
<method name="itemSelected" event="onclick">
<![CDATA[
Debug.write("Field Clicked");
editor.datapath.setFromPointer(this.datapath.dupePointer());
]]>
</method>
</view>
<view
datapath="testds:/outerElement/innerElements/innerElement[4]"
width="${parent.width}">
<edittext name="test" datapath="@uri" width="600"
bgcolor="white"/>
</view>
<view id="editor" width="${parent.width}">
<datapath/>
<edittext name="test2" datapath="@uri" width="600"
bgcolor="white"/>
</view>
<button>Click
<method event="onclick">
<![CDATA[
Debug.write("Click!");
// var pointer = testds.getPointer();
selectedUserChannel = outerElement.dupePointer();
var adjUri =
LzBrowser.xmlEscape("http://foo.bar.com/five");
var ptr =
selectedUserChannel.setXPath("testds:/outerElement/innerElements/[EMAIL
PROTECTED]'"
+ adjUri + "']");
Debug.write(ptr);
if (ptr) {
Debug.write("Success!");
}
else {
Debug.write("Blah");
}
adjUri = LzBrowser.xmlEscape("http://foo.bar.com/two");
ptr =
selectedUserChannel.setXPath("testds:/outerElement/innerElements/[EMAIL
PROTECTED]'"
+ adjUri + "']");
Debug.write(ptr);
if (ptr) {
Debug.write("Success!");
}
else {
Debug.write("Blah");
}
]]>
</method>
</button>
</view>
<script>
LzLoadQueue.qargs.push('headers');
</script>
</canvas>
Thanks!
--
James Howe
_______________________________________________
Laszlo-user mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-user