[augeas-devel] XML lens parse_error with XML document using single quotes
David Lutterkort
lutter at redhat.com
Fri Nov 11 19:46:26 UTC 2011
On Tue, 2011-11-08 at 00:40 -0500, Francis Giraldeau wrote:
> You're right. This is a limitation of the current lens. Here is the
> comment from the lens:
>
> (* if we hide the quotes, then we can only accept single or double
> quotes otherwise a put ambiguity is raised *)
>
> The put ambiguity is raised because for the same tree, two lenses match.
> One way to overcome this would be to accept malformed files, where a
> quote may not be balanced i.e. att="var'.
>
> let example = [ key /[a-z]+/ . dels "=" . del /["']/ "\"" .
> store /[a-z]*/ . del /["']/ "\"" ]
>
> Maybe a lens like the square lens, but that acts as a del with
> characters at extremity? Or quotient lens?
I agree .. since handling quoted strings is such a common thing, and
always a big headache, I think having a lens dedicated to it would be
very helpful. I guess we should have made square a little more
complicated, namely,
square l1 l2 l3 = l1 . l2 . l3
with the additional constraint that whatever matches l1 must be
identical to what matches l3 in the get direction.
We could also add a special-purpose builtin dedicated to handling quoted
strings, i.e. something like
quoted R1 D1 R2 D2 L = del R1 D1 . L . del R2 D2
with the same constraint as square.
Of course, I'd prefer the first option, but I am not sure how hard it
would be to implement.
David
More information about the augeas-devel
mailing list