Re: [OT] XML

2012-11-27 Thread Vincent Lefevre
On 2012-11-26 20:32:17 +0100, olivier sallou wrote:
 XML is nice for internal config, message/config exchanges, etc... help with
 its structure and its DTD to force/help understanding the schema.
 
 BUT definitely not useable by an end user for end-user config. It is very
 hard to read (opening an XML with vi is a ass). Not everybody is using a
 Desktop with editors etc...

Emacs + nXML mode is quite fine to read XML file and it can run in
a terminal (just like vi). Simple XML files are easily readable in
general. Complex ones much less, but I doubt that a complex plain
text based config file would be readable as well.

 Plain text is readeable by non-IT people, quick to read and update.
 
 Manually updating XML can be a pain when modifying its structure and hard
 to repair, even with tools (not always explicit on exact error position).

No problems with Emacs. It tells you in real time whether the XML file
is valid (by default, just well-formed) or not. And when there's an
error, it can tell you where.

Something I've never seen with plain text config files.

-- 
Vincent Lefèvre vinc...@vinc17.net - Web: http://www.vinc17.net/
100% accessible validated (X)HTML - Blog: http://www.vinc17.net/blog/
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)


-- 
To UNSUBSCRIBE, email to debian-devel-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/20121127094039.ga5...@xvii.vinc17.org



Re: [OT] XML

2012-11-27 Thread Thomas Goirand
On 11/27/2012 05:40 PM, Vincent Lefevre wrote:
 On 2012-11-26 20:32:17 +0100, olivier sallou wrote:
 XML is nice for internal config, message/config exchanges, etc... help with
 its structure and its DTD to force/help understanding the schema.

 BUT definitely not useable by an end user for end-user config. It is very
 hard to read (opening an XML with vi is a ass). Not everybody is using a
 Desktop with editors etc...
 Emacs + nXML mode is quite fine to read XML file and it can run in
 a terminal (just like vi). Simple XML files are easily readable in
 general. Complex ones much less, but I doubt that a complex plain
 text based config file would be readable as well.

As I've been doing a bit of FreeSwitch configuration, I can tell that
XML are not practical at all, and abusing it is even worse. Telling
oh, it's easy, just use emacs isn't a viable solution (note everyone
likes / uses / knows emacs).

 No problems with Emacs. It tells you in real time whether the XML file
 is valid (by default, just well-formed) or not. And when there's an
 error, it can tell you where.

 Something I've never seen with plain text config files.
Plaintext (whatever that means...), probably not, but YAML and
the .ini format can both be validated with some tools. For example:

RET=$(python -c import configobj
config=configobj.ConfigObj('${FILE}')
print config['${SECTION}']['${DIRECTIVE}'])  

will do the necessary structure checks, and returns the value
of DIRECTIVE inside the SECTION of your FILE (thanks to lo-lan-do
for this example, which we use in the Openstack packaging btw,
as Openstack uses the .ini format which appeared very practical
and easy to hack).

Thomas


-- 
To UNSUBSCRIBE, email to debian-devel-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/50b4d685.4010...@debian.org



Re: [OT] XML

2012-11-26 Thread Jakub Wilk

* Ivan Shmakov oneing...@gmail.com, 2012-11-26, 14:32:
Seriously, XML takes a lot of concerns off an application programmer. 
It provides quoting, arbitrary hierarchical structure, support for 
different encodings, etc. Why, don't you think that $ grep 
'[[:lower:]]' FILE is ever supposed to work? For surely it isn't: grep 
has no way to know the encoding of the input file, and relies on the 
locale instead. On the contrary, XML allows for the encoding to be 
specified explicitly via a processing instruction. And then, there's 
XPath, which takes the input dataset structure into account.


How do you search for a lowercase letter in XPath?

--
Jakub Wilk


--
To UNSUBSCRIBE, email to debian-devel-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/20121126115235.ga1...@jwilk.net



Re: [OT] XML

2012-11-26 Thread Chow Loong Jin
On 26/11/2012 19:52, Jakub Wilk wrote:
 * Ivan Shmakov oneing...@gmail.com, 2012-11-26, 14:32:
 Seriously, XML takes a lot of concerns off an application programmer. It
 provides quoting, arbitrary hierarchical structure, support for different
 encodings, etc. Why, don't you think that $ grep '[[:lower:]]' FILE is ever
 supposed to work? For surely it isn't: grep has no way to know the encoding 
 of
 the input file, and relies on the locale instead. On the contrary, XML allows
 for the encoding to be specified explicitly via a processing instruction. And
 then, there's XPath, which takes the input dataset structure into account.
 
 How do you search for a lowercase letter in XPath?
 

Can't [[:lower:]] work with re:test(...) using the
http://exslt.org/regular-expressions namespace?

-- 
Kind regards,
Loong Jin



signature.asc
Description: OpenPGP digital signature


Re: [OT] XML

2012-11-26 Thread Ivan Shmakov
 Jakub Wilk jw...@debian.org writes:
 * Ivan Shmakov oneing...@gmail.com, 2012-11-26, 14:32:

  Seriously, XML takes a lot of concerns off an application
  programmer. It provides quoting, arbitrary hierarchical structure,
  support for different encodings, etc.  Why, don't you think that
  $ grep [[:lower:]]' FILE is ever supposed to work?  For surely it
  isn't: grep has no way to know the encoding of the input file, and
  relies on the locale instead.  On the contrary, XML allows for the
  encoding to be specified explicitly via a processing instruction.
  And then, there's XPath, which takes the input dataset structure
  into account.

  How do you search for a lowercase letter in XPath?

With fn:matches (WHERE, \p{Ll})?

Specifically, if you're interested in all ENTRY elements, whose
respective KEY's contain a lower-case letter, it may look
something like the following:

//x:entry[fn:matches (x:key/text (), \p{Ll})]

For instance, using xqilla(1) (xmlstarlet(1) doesn't seem to
support fn:matches ()):

$ cat  cf.xml 
!DOCTYPE cf
cf xmlns=urn:uuid:95364fc4-e68d-492e-a122-7b3b37bdab10
  entry
keythere be an all-lowercase key/key
valueall-lowercase key's value/value
  /entry
  entry
keyTHERE BE AN ALL-UPPERCASE KEY/key
valueall-uppercase key's value/value
  /entry
  entry
keyThere be a Mixed-case Key/key
valuemixed-case key's value/value
  /entry
/cf
$ xqilla -i cf.xml \
  (printf %s\\n '\
declare namespace x=urn:uuid:95364fc4-e68d-492e-a122-7b3b37bdab10;' \
'//x:entry[fn:matches (x:key/text (), \p{Ll})]') 
entry xmlns=urn:uuid:95364fc4-e68d-492e-a122-7b3b37bdab10
keythere be an all-lowercase key/key
valueall-lowercase key's value/value
  /entry
entry xmlns=urn:uuid:95364fc4-e68d-492e-a122-7b3b37bdab10
keyThere be a Mixed-case Key/key
valuemixed-case key's value/value
  /entry
$ 

-- 
FSF associate member #7257


-- 
To UNSUBSCRIBE, email to debian-devel-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/86mwy34ojh@gray.siamics.net