When your .lzx file is parsed:
<data><ABCD></data>
will be stored internally as a data node with the text `<ABCD>`. You
have to use < to get past the XML parser:
<data><ABCD></data>
would parse ABCD as an empty child node (and give an error because
there is no matching end tag). `<` escapes the `<` past the XML
parser, so that it is treated as text (or character data), rather
than the beginning of an XML tag. You could also have said:
<data><![CDATA[<ABCD>]]></data>
`<![CDATA[` tells the XML parser to not treat `<` and `&` as special
characters until the matching `]]>` is hit.
Serialize will unescape the data contents because its contract is to
create a representation that can be parsed (unserialized) back to the
original data. So it shows `<ABCD>`. xpathQuery returns the
raw data `<ABCD>`. If you want the result of the query to be
escaped, you would have to do it yourself:
Debug.write( "escaped dp xpathQuery: " + LzBrowser.xmlEscape
(dp.xpathQuery("data/text()")) );
On 2007-03-12, at 22:25 EDT, Daniel Williams wrote:
mt1,
I would think that Laszlo would call a 3rd party library for
parsing the XML.
You may want to ask the developers how they parse the XML for a
dataset.
Happy hunting...
-Daniel
mt1 wrote:
Daniel,
Thank you for your point.
And i am sorry cause of my dump, but i do not understand what you
said.
I know i am using a strict character.
My question is
1. described in the dataset tag &#60;ABCD&#62;
2. when using serialize() &#60;ABCD&#62;
3. when using xpathQuery() <ABCD>
In the case of 2, transferred '&' to '&'.
In the case of 3, transferred '&' to '&'.
And in the example code of setText() transferred '<' to '<'
when it shown in then view.
where those are converted to ? *.as, *.lzx or LPS ?
I could not find out the converting mechanism of strict characters.
Give me some hints.
mt1
Daniel Williams wrote:
mt1,
I missed the #38 before the ">", that's way it was displayed in the
debug window.
So the data should read &#60;ABCD&#62;
My point is this http://www.w3.org/TR/REC-xml/#sec-external-ent,
your
working with XML which has a strict character set.
-Daniel
mt1 wrote:
Thank you Daniel, but I am getting confuse more.
Your code has shown "<ABCD> " in the debug window and
"<ABCD>" in
the text area.
That mean xpathQuery() could not handle '&#60;' but <text>
tag could
do it, right?
Where your point is ?
Thx
mt1
Daniel Williams wrote:
mt1,
I don't think this is a Laszlo code issue. You may need to use the
numeric reference , here is a list.
Ampersand & & &#38;
Left angle bracket < < &#60;
Right angle bracket > > >
Straight quotation mark " " '
Apostrophe ' ' "
Try this code out if you want to display "<ABCD>" to the user,
FYI I'm
running 3.3.3 .
<canvas debug="true">
<dataset name="ds">
<data>&#60;ABCD></data>
</dataset>
<handler name="oninit">
var dp = new LzDatapointer();
dp.setPointer(ds);
Debug.write( "dp serialize : " + dp.serialize() );
Debug.write( "dp xpathQuery: " + dp.xpathQuery("data/text()") );
var text = dp.xpathQuery('data/text()');
testText.setAttribute('text', text);
</handler>
<view bgcolor="blue" width="100" height="100">
<text id="testText" resize="true" text="Hello"/>
</view>
</canvas>
Just my 2 cents.
-Daniel
mt1 wrote:
Any hints?
mt1 wrote:
Yes i thought so, but there were not it in xpathQuery()
method or
*.as files.
So i confused where it has been done.
You can see that where is ?
Thanks
mt1
Not Zippy wrote:
I believe the data is being unescaped.
Debug.write(unescape("<ABCD>") )
On 3/5/07, *mt1* < [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>>
wrote:
Hi forks,
I am wondering how to handle a escape characters in
LzDatapointer.xpathQuery().
This is a example code.
<canvas debug="true">
<dataset name="ds">
<data><ABCD></data>
</dataset>
<handler name="oninit">
var dp = new LzDatapointer();
dp.setPointer(ds);
Debug.write( "dp serialize : " + dp.serialize() );
Debug.write( "dp xpathQuery: " + dp.xpathQuery("data/text
()") );
</handler>
</canvas>
You can see the data with escaped in <dataset> tag.
And the first debug line ( using serialize() ) shows the
strings
without
modification,
but the second debug line ( using xpathQuery() ) shows "<ABCD>"
out of
the way by
operating unescaped.
I took a look around LzDatapointer.as or LzDataElement.as, but
xpathQuery() do not
translate from '>' to '<' anywhere.
Please let me know why xpathQuery() can do such like that ?
mt1