PDA

View Full Version : Problem with data pointer


aulio
06-12-2007, 01:14 AM
I have a following dataset in which the block element has been created dynamically.

<dataset name="editorData">
<textBlocks>
<block ref="123">Text in dataset.</block>
</textBlocks>
</dataset>

I set the data pointer as follows:

pointer.setXPath("editorData:/textBlocks[1]/block[@ref='123']");

Then

pointer.xpathQuery("editorData:/textBlocks[1]/block[@ref='123'")

outputs

<block ref="123">Text in dataset.</block>

But the pointer.isValid() method gives me false. Also, I'm not able to delete the node, set node text, etc. It feels like the pointer points to a kind of nodeset instead of a single node.

Can you tell what is the problem?

senshi
06-12-2007, 09:38 AM
Cannot reproduce:

<canvas debug="true" >

<dataset name="editorData">
<textBlocks />
</dataset>

<handler name="oninit" >
editorData.getFirstChild().appendChild( new LzDataElement( "block", {ref:"123"}, [new LzDataText("Text in dataset")] ) );
editorData.getFirstChild().appendChild( new LzDataElement( "block", {ref:"456"}, null ) );
editorData.getFirstChild().appendChild( new LzDataElement( "block", {ref:"789"}, null ) );

var dp = new LzDatapointer(null);
dp.setXPath( "editorData:/textBlocks[1]/block[@ref='123']" );
Debug.write( dp.xpathQuery( "editorData:/textBlocks[1]/block[@ref='123']" ) );
Debug.write( dp.isValid() );
delete dp;
</handler>

</canvas>

aulio
06-13-2007, 01:49 AM
Yeah, you're right. I had typo in my code. This time, it took hours to note it.