#1791 closed defect (fixed)
gui modeler: cannot load file with r.mapcalc expression containing '&&' operator
Reported by: | mlennert | Owned by: | |
---|---|---|---|
Priority: | normal | Milestone: | 7.0.0 |
Component: | wxGUI | Version: | svn-trunk |
Keywords: | modeler r.mapcalc | Cc: | |
CPU: | Unspecified | Platform: | Unspecified |
Description
I have a model in which I use r.mapcalculator with the '&&' operator:
<parameter name="formula"> <value>if(A==0 && B> 4, 1, A)</value> </parameter>
After saving the model to a file, I cannot load it back into the modeler. Instead I get the following error:
self._parser.Parse(data, 0) xml.parsers.expat . ExpatError : not well-formed (invalid token): line 46, column 32
Moritz
Change History (4)
comment:1 by , 11 years ago
Keywords: | r.mapcalc added |
---|---|
Milestone: | 6.4.3 → 7.0.0 |
Version: | unspecified → svn-trunk |
follow-up: 3 comment:2 by , 11 years ago
Thanks for reminding about this issue. It is actually trivial (at least I hope that I haven't overlooked something). Should be fixed for trunk in r58371.
I tested it but it would be better if you test it, too, XML can be tricky.
For reference, I used xml.sax.saxutils instead of custom escape function. See also a list of XML entities.
follow-up: 4 comment:3 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Replying to wenzeslaus:
Thanks for reminding about this issue. It is actually trivial (at least I hope that I haven't overlooked something). Should be fixed for trunk in r58371.
I tested it but it would be better if you test it, too, XML can be tricky.
It works here when you create a new model file. One which already contains '&&' still cannot be loaded (which is logical as your change concerns writing the file), but I guess that this cannot be easily solved and that your solution is good enough. Any existing model files still have to be handled manually, but as soon as you save them again the issue is solved.
I'm closing the bug for now.
Thanks for the quick fix !
Moritz
comment:4 by , 11 years ago
Replying to mlennert:
It works here when you create a new model file. One which already contains '&&' still cannot be loaded (which is logical as your change concerns writing the file), but I guess that this cannot be easily solved and that your solution is good enough. Any existing model files still have to be handled manually, but as soon as you save them again the issue is solved.
Yes of course, I forgot to mention. It now writes a well-formed XML and also reads well-formed XML (as before).
So, if you have existing .gxm
file you need to load it with error and than fix the damaged expressions or other parameters, or you can open the .gxm
in text editor and replace (probably all) occurrences of &&
by &&
. Doing so, you will create a well-formed XML from your old XML (e.g. Gedit highlights &&
as invalid syntax). Example file part:
<task name="r.mapcalc"> <parameter name="expression"> <value>elevation && aspect</value> </parameter> </task>
Looking at the list at Wikipedia, other entities were already handled correctly (<
and >
) or are probably not an issue ("
and '
) for our case.
This ticket is still valid in grass7
Only the error message has changed:
Erasing the '&&' in the .gxm file allows to load it, but you then have to manually enter it again.
Moritz