Changeset 4437:6f3d4e845072 in livinglogic.python.xist for src/ll/xist/scripts/xml2xsc.py

Show
Ignore:
Timestamp:
03/25/11 15:57:19 (8 years ago)
Author:
Walter Doerwald <walter@…>
Branch:
default
Message:

Fix typos in script documentation. Add examples. Bump version number.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/ll/xist/scripts/xml2xsc.py

    r4433 r4437  
    1111 
    1212""" 
     13Purpose 
     14------- 
     15 
    1316``xml2xsc`` is a script that generates an XIST namespace module from one or more 
    1417XML files. ``xml2xsc`` will output an XIST element class for each element it 
     
    1720element in the XML files, so the XML files should cover as many different cases 
    1821as possible. 
     22 
     23 
     24Options 
     25------- 
    1926 
    2027``xml2xsc`` supports the following options: 
     
    4855 
    4956    .. _lxml: http://lxml.de/ 
     57 
     58 
     59Example 
     60------- 
     61 
     62Suppose we have the following XML file (named ``foo.xml``):: 
     63 
     64    <x a="0"><x b="1"/><y/></x> 
     65 
     66Then we can generate a skeleton XIST namespace from it with the following command:: 
     67 
     68    xml2xsc foo.xml -xhttp://xmlns.example.org/ -mfullonce 
     69 
     70The output will be:: 
     71 
     72    # -*- coding: ascii -*- 
     73 
     74 
     75    from ll.xist import xsc, sims 
     76 
     77 
     78    xmlns = 'http://xmlns.example.org/' 
     79 
     80 
     81    class x(xsc.Element): 
     82        xmlns = xmlns 
     83        class Attrs(xsc.Element.Attrs): 
     84            class a(xsc.TextAttr): pass 
     85            class b(xsc.TextAttr): pass 
     86 
     87 
     88    class y(xsc.Element): xmlns = xmlns 
     89 
     90 
     91    x.model = sims.Elements(y, x) 
     92    y.model = sims.Empty() 
    5093""" 
    5194