Changeset 4278:56852276638d in livinglogic.python.xist for src/ll/xist/scripts/xml2xsc.py

Show
Ignore:
Timestamp:
12/17/10 17:03:27 (9 years ago)
Author:
Walter Doerwald <walter@…>
Branch:
default
Message:

Enhance dtd2xsc so that it can put the content of more than one DTD into a xnd definition.

Files:
1 modified

Legend:

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

    r4114 r4278  
    4040def etree2xnd(model, node): 
    4141    ns = xnd.Module() 
    42     elements = {} # maps (name, xmlns) to (xnd.Element, content set, attrname->xnd.Attr map) 
     42    elements = {} # maps (name, xmlns) to (xnd.Element, content set) 
    4343    procinsts = {} # maps name to xnd.ProcInst 
    4444 
    45     # Iterate through the tree a collect: which elements are encountered and how they are nested 
     45    # Iterate through the tree and collect which elements are encountered and how they are nested 
    4646    for path in iterpath(node): 
    4747        node = path[-1] 
     
    5252            except KeyError: 
    5353                xndnode = xnd.Element(name, xmlns=xmlns) 
    54                 entry = elements[(name, xmlns)] = (xndnode, set(), {}) 
     54                entry = elements[(name, xmlns)] = (xndnode, set()) 
    5555                ns(xndnode) 
    5656            else: 
    5757                xndnode = entry[0] 
    5858            for attrname in node.keys(): 
    59                 if not attrname.startswith("{") and attrname not in entry[2]: 
    60                     attr = xnd.Attr(attrname, type=xsc.TextAttr) 
    61                     entry[0](attr) 
    62                     entry[2][attrname] = attr 
     59                if not attrname.startswith("{") and attrname not in entry[0].attrs: 
     60                    entry[0](xnd.Attr(attrname, type=xsc.TextAttr)) 
    6361        elif "ProcessingInstruction" in type(node).__name__: 
    6462            name = node.target