why XHTML cannot be parsed with RevXML ?

paolo mazza paolo.mazza at neol.it
Mon Mar 17 12:44:57 EDT 2008


I find very difficult to  manage the XHTML code with the RevXML tools if
these tools do not manage consistently some special chars like  & .

Consider this: I want to change some words in this  XHTML page (field
"FieldXML")

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<title>
XHTML page
</title>
</head>
<body><h1>Welcome</h1><p>TEXT</p></body>
</html>

I use this script:

on mouseUp
revDeleteAllXMLTrees
put RevCreateXMLTree(field "FieldXML",true,true,false) into  NUMERO
revPutIntoXMLNode NUMERO,"html//body/p[1]","Char è "
put revXMLText(NUMERO) into CODICE
put CODICE into message
set the HtmlText of field "browser" to CODICE
end mouseUp


The text in field "browser" will be:

Welcome

Char è  


What's wrong with my script? How can I get the correct XHTML code?

I thought it was a bug (
http://quality.runrev.com/qacenter/show_bug.cgi?id=6061 ) . But they told
me I was wrong (see the following message from Mark). I can not find a
solution to thi problem.


Hi Paolo,

Thanks for the report.

This change in behaviour is due to the fix to Bug 5283 - the behaviour of
revPutIntoXMLNode, revAppendXMLNode and revXMLText is now correct and
consistent. Both PutIntoXMLNode and AppendXMLNode assume that you are given
them a string of text encoded in the native encoding of the XML file (the
attribute in the ?xml header). In particular, they will escape the uses of
'<',
'>' and '&'.

Unless you attach a DTD to you XML document, the only entities defined are
lt,
gt, quot, and amp. In particular, if you wish to use entities from HTML you
need to add explicit <!ENTITY ...> definitions to your XML tree. (egrave
is one
such entity).

Therefore, if you want to read an XML document which uses entities, you
need to
ensure it either has a DTD attached, or the <!ENTITY ...> declarations at
the
start. After such a document has been read into memory, however, you can
use
things such as XMLNodeContents and PutIntoXMLNode to manipulate the text
content *without* using entities.

Warmest Regards,

Mark.



How to use Revolution <use-revolution at lists.runrev.com> writes:
>On Fri, 14 Mar 2008 14:54:05 +0100, David Bovill wrote:
>
>> Paolo - from memory the issue is not that you cannot parse valid XHTML
>with
>> Revs XML externals, rather that Revs native htmltext is not valid XML
>and
>> therefore cannot be parsed using Revs XML externals! Strange but true.
>> However from memory the problem is caused by html entities not being
>escaped
>> in htmltext and breaking the XML parsing. You can get around this by
>> replacing the htmltext enitities with XML compliant ones.
>> 
>> You should not have any problems with valid XHTML though.
>
>Right, that's my understanding as well... the main issue for XML 
>parsers is that a lot of HTML is not compliant - for example using a 
>single <P> instead of <P></P>. This leaves an open tag without a 
>closing tag. Now if it is *valid* XHTML, you *should* be able to parse 
>the tags with XML parsing tools (Rev's included). Can you provide an 
>example of compliant XHTML syntax that doesn't parse? Just curious...
>
>Ken Ray
>Sons of Thunder Software, Inc.
>Email: kray at sonsothunder.com
>Web Site: http://www.sonsothunder.com/
>_______________________________________________
>use-revolution mailing list
>use-revolution at lists.runrev.com
>Please visit this url to subscribe, unsubscribe and manage your
>subscription preferences:
>http://lists.runrev.com/mailman/listinfo/use-revolution



******************************************

Paolo Mazza
NEOL SRL
Società partecipata da Università di Padova
via N. Tommaseo 84
35131 - Padova (Italy)
Tel 049- 2050147 - Fax 049-7964386
www.neol.it




More information about the use-livecode mailing list