Edit detail for XMLinLeo revision 3 of 3

1 2 3
Editor: terry_n_brown
Time: 2007/12/17 08:18:08 GMT-8
Note:

changed:
-[20071217: rather than using this, check out Leo's @auto file support for XML]
(20071217: rather than using this, check out Leo's @auto file support for XML)

This is working demo of a method for editing arbitrary XML in Leo.

(20071217: rather than using this, check out Leo's @auto file support for XML)

WARNING: the script overwrites the file named by the selected node without warning. Apart from this warning, that is.

I don't have time right now to wrap it up as a proper plugin. Just make a script button from the node 'leo2xml' and run it with a node containing a filename selected. The file will be written using selected node's children to generate XML using the following rules:

  • If a headString contains only letters, numbers, '_' and ':' it's assumed to be an element name - this is weak but will usually work.
  • Anything else, like <!-- comments and <DOCTYPEs, is written as is with a newline at the end of the line.
  • For nodes that are elements, lines in the bodyString that match the pattern @ns:myAttrib="foo bar" are assumed to be attributes belonging to the element. 'ns:' is optional and either " or ' work.
  • After any elements are removed, the bodyString is written as is.

XMLinLeo.leo