[augeas-devel] Named key

Francis Giraldeau francis.giraldeau at usherbrooke.ca
Wed Apr 21 06:54:12 UTC 2010


Hi, 

While developing the httpd lens, there are some xml-like elements, where
open and close tags must be the same. We can do this now with lens and a
string argument, like this small html example (I removed "<>" chars and
element content to simplify the example) : 

let elem (name:string) = [ key name . del ws " " . del name name ]
let doc = elem "body" | elem "html" | elem "img" ...

The drawback of this method is that we have to list every element name
that may occur in a document. Such a lens will not be able to handle
arbitrary xml document. 

We need to get a reference on a matched key value. To start discussion
on that, let's say we add a new keyword "as" to reference a value as a
string type. Then, we could use this name elsewhere in the same subtree.
Here is a small example. 

let x = [ key /[a-z]+/ as name . del ws " " . del name name ]
test x get "abc abc" = { "abc" }
test x put "abc abc" after rm "/abc"; set "/def" ""  = "def def"

The behavior of del has to be a bit modified. In the get direction, it
has to match exactly the same string as the key, and in the put
direction, it has to check if the value has been updated and use it.
Also, it is mandatory to get the key defined first, otherwise "name" is
not defined. 

Typechecking would be simply done with the regexp that corresponds to
the key. 

Does it make sens? Maybe another lens should do the trick? 

Cheer, 

Francis





More information about the augeas-devel mailing list