Changeset 4289:e40f5dc756bf in livinglogic.python.xist for src/ll/xist/scripts/dtd2xsc.py

Show
Ignore:
Timestamp:
01/20/11 17:23:12 (9 years ago)
Author:
Walter Doerwald <walter@…>
Branch:
default
Message:

Enhance xml2xsc.py so it can read multiple XML files.

xnd genating function can now read source from URLs, strings and streams.

Files:
1 modified

Legend:

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

    r4288 r4289  
    5555 
    5656 
    57 def adddtd2xnd(ns, dtd, xmlns=None, duplicates="reject"): 
     57def adddtd2xnd(ns, dtd, xmlns=None, model="simple", duplicates="reject"): 
    5858    """ 
    5959    Append DTD information from :var:`dtd` to the :class:`xnd.Module` object 
     
    140140                    modeltype = "sims.NoElementsOrText" 
    141141        e = ns.elements[(elemname, xmlns)] 
     142        if model == "simple": 
     143            modeltype = modeltype == "sims.Empty" 
     144            modelargs = None 
    142145        e.modeltype = modeltype 
    143146        e.modelargs = modelargs 
     
    182185    p.add_argument("-x", "--xmlns", dest="xmlns", metavar="NAME", help="the namespace name for this module") 
    183186    p.add_argument("-s", "--shareattrs", dest="shareattrs", help="Should identical attributes be shared among elements? (default: %(default)s)", choices=("none", "dupes", "all"), default="dupes") 
    184     p.add_argument("-m", "--model", dest="model", default="once", help="Add sims information to the namespace (default: %(default)s)", choices=("no", "all", "once")) 
     187    p.add_argument("-m", "--model", dest="model", default="once", help="Add sims information to the namespace (default: %(default)s)", choices=("no", "simple", "fullall", "fullonce")) 
    185188    p.add_argument("-d", "--defaults", dest="defaults", help="Output default values for attributes? (default: %(default)s)", action=misc.FlagAction, default=False) 
    186189    p.add_argument(      "--duplicates", dest="duplicates", help="How to handle duplicate elements from multiple DTDs (default: %(default)s)", choices=("reject", "allow", "merge"), default="reject") 
    187190 
    188191    args = p.parse_args(args) 
    189     print urls2xnd(args.urls, args.xmlns, args.shareattrs, args.duplicates).aspy(model=args.model, defaults=args.defaults) 
     192    print urls2xnd(args.urls, args.xmlns, args.shareattrs, args.model, args.duplicates).aspy(model=args.model, defaults=args.defaults) 
    190193 
    191194