Changeset 4432:1733a94c86bf in livinglogic.python.xist

03/21/11 14:32:36 (8 years ago)
Walter Doerwald <walter@…>

Finish documentation for xml2xsc.

1 modified


  • src/ll/xist/scripts/

    r4425 r4432  
    1313``xml2xsc`` is a script that generates an XIST namespace module from one or more 
    14 XML files. 
     14XML files. ``xml2xsc`` will output an XIST element class for each element it 
     15encounters in any of the XML files. The attributes and model information 
     16``xml2xsc`` assigns to an element will be collected from each occurence of the 
     17element in the XML files, so the XML files should cover as many different cases 
     18as possible. 
     20``xml2xsc`` supports the following options: 
     22    ``urls`` 
     23        One or more URLs (or filenames) of XML files to be parsed 
     25    ``-p``, ``--parser`` : ``etree`` or ``lxml`` 
     26        Which XML parser should be used from parsing the XML files? (``etree`` is 
     27        the default, ``lxml`` requires that lxml_ is installed) 
     29    ``-s``, ``--shareattrs`` : ``none``, ``dupes``, ``all`` 
     30        Should attributes be shared among the elements? ``none`` means that each 
     31        element will have its own standalone :class:`Attrs` class directly derived 
     32        from :class:`ll.xist.Elements.Attrs`. For ``dupes`` each attribute that is 
     33        used by more than one element will be moved into its own :class:`Attrs` 
     34        class. For ``all`` this will be done for all attributes. 
     36    ``-m``, ``--model`` : ``no``, ``simple``, ``fullall``, ``fullonce`` 
     37        Add model information to the namespace. ``no`` doesn't add any model 
     38        information. ``simple`` only adds ``model = False`` or ``model = True`` 
     39        (i.e. only the information whether the element must be empty or not). 
     40        ``fullall`` adds a :mod:`ll.xist.sims` model object to each element class. 
     41        ``fullonce`` adds full model information to, but reuses model objects for 
     42        elements which have the same model. 
     44    ``-x``, ``--defaultxmlns`` 
     45        The default namespace name. All elements that don't belong to any 
     46        namespace will be assigned to this namespace. 
     48    .. _lxml: 
    133167def main(args=None): 
    134168    p = argparse.ArgumentParser(description="Convert XML files to XIST namespace (on stdout)") 
    135     p.add_argument("urls", metavar="urls", type=url.URL, help="ULRs of DTDs to be parsed", nargs="+") 
     169    p.add_argument("urls", metavar="urls", type=url.URL, help="URLs of XML files to be parsed", nargs="+") 
    136170    p.add_argument("-p", "--parser", dest="parser", help="parser module to use for XML parsing (default: %(default)s)", choices=("etree", "lxml"), default="etree") 
    137171    p.add_argument("-s", "--shareattrs", dest="shareattrs", help="Should identical attributes be shared among elements? (default: %(default)s)", choices=("none", "dupes", "all"), default="dupes")