Annotation of xmlschema/applyschema.py, revision 1.47

1.44      ht          1: # Copyright (C) 2000 LTG -- See accompanying COPYRIGHT and COPYING files
1.24      ht          2: # actually apply a schema to an instance
1.47    ! richard     3: # $Id: applyschema.py,v 1.46 2000/04/27 09:41:18 ht Exp $
1.24      ht          4: 
1.2       ht          5: from PyXML import *
                      6: from XML import *
1.41      ht          7: import XMLSchema
1.28      ht          8: import layer
1.3       aqw         9: import sys
1.4       richard    10: import re
1.18      ht         11: import xpath
1.20      ht         12: import types
1.41      ht         13: import string
1.4       richard    14: 
                     15: whitespace = re.compile("^[ \t\r\n]*$")
1.33      ht         16: xsi = "http://www.w3.org/1999/XMLSchema-instance"
1.47    ! richard    17: vsraw="$Revision: 1.46 $ of $Date: 2000/04/27 09:41:18 $"
1.40      ht         18: vss=string.split(vsraw)
1.41      ht         19: vs="XSV %s/%s of %s %s"%(string.split(XMLSchema.versionString)[0],
1.40      ht         20:                          vss[1],vss[5],vss[6])
1.5       richard    21: 
1.2       ht         22: def readXML(url):
1.14      ht         23:   input = Open(url, NSL_read|NSL_read_namespaces|NSL_read_defaulted_attributes)
1.5       richard    24: #  item = GetNextQueryItem(input, ParseQuery(input.doctype, "."))
                     25: #  elem = Element(item, input.doctype)
                     26:   elem = Element(input, 1)
1.2       ht         27:   Close(input)
1.33      ht         28:   return elem                           # error return??
1.2       ht         29: 
1.20      ht         30: def validate(element, typedef, schema):
1.33      ht         31:   schema.factory.errors=0
                     32:   validateElement(element, typedef, schema)
                     33:   return schema.factory.errors
1.2       ht         34: 
1.21      ht         35: def validateElement(element, type, schema,eltDecl=None):
1.4       richard    36:   global vel, vtype
                     37:   vel = element
                     38:   vtype = type
1.2       ht         39: #  print "validating element %s against %s" % (element.name, type)
1.47    ! richard    40:   if not eltDecl:
        !            41:     eqn=XMLSchema.QName(None,element.local,element.uri)
        !            42:     if s.vElementTable.has_key(eqn):
        !            43:       eltDecl=s.vElementTable[eqn]
        !            44: #  nullable = eltDecl and eltDecl.nullable
1.31      richard    45:   if element.nsattrs.has_key((xsi, "type")):
                     46:     t = element.nsattrs[(xsi, "type")].value;
                     47:     try:
1.41      ht         48:       qt = XMLSchema.QName(t, element.nsdict)
1.31      richard    49:     except SchemaError:
1.33      ht         50:       verror(element,"namespace not found for xsi:type %s" % t,schema)
                     51:       return
1.31      richard    52:     if schema.vComplexTypeTable.has_key(qt):
                     53:       xsitype=schema.vComplexTypeTable[qt]
                     54:     elif schema.vSimpleTypeTable.has_key(qt):
                     55:       xsitype=schema.vSimpleTypeTable[qt]
                     56:     else:
1.33      ht         57:       verror(element,"xsi:type %s undefined" % qt,schema)
                     58:       return
1.31      richard    59:     if not xsitype.isSubtype(type):
1.33      ht         60:       verror(element,"xsi:type %s is not a subtype of the declared type %s" % (qt, type.name),schema)
                     61:       return
                     62:     vwarn(element,"using xsi:type %s instead of original %s" % (qt, type.name))
                     63:     type = xsitype
                     64:   if type:
                     65:     # might have none in case of recursive call inside <any/>
1.41      ht         66:     if isinstance(type, XMLSchema.AbInitio):
1.33      ht         67:       return validateElementSimple(element, type, schema)
1.41      ht         68:     if isinstance(type, XMLSchema.SimpleType):
1.33      ht         69:       return validateElementSimple(element, type.primitiveType, schema)
                     70:     assignAttributeTypes(element, type.attributeDeclarations,
                     71:                               type.prohibitedSubstitutions, schema)
                     72:     validateAttributeTypes(element, element.attrTable,
                     73:                            type.attributeDeclarations, schema)
                     74:   #  print "assigning types for %s" % element.name
                     75:     assignChildTypes(element.children, type.elementTable,
                     76:                           type.prohibitedSubstitutions, schema)
                     77:     # we must look at the content model before checking the types, so that
                     78:     # we know which children matched <any>
                     79:     validateContentModel(element, type, schema)
                     80:   validateChildTypes(element.children, schema)
1.21      ht         81:   if eltDecl:
1.33      ht         82:     validateKeys(eltDecl,element)
1.2       ht         83: 
                     84: def validateElementSimple(element, type, schema):
                     85:   # check that:
1.47    ! richard    86:   #   it has no attributes (except xsi: ones)
1.2       ht         87:   #   it has one pcdata child, and if so
                     88:   #     the text of the pcdata matches the type
                     89:   if element.attrs:
1.47    ! richard    90:     for a in element.attrs.values():
        !            91:       if a.uri != xsi:
        !            92:         verror(element,"element {%s}%s with simple type not allowed attributes" % (element.uri, element.name),schema)
        !            93:         return
1.2       ht         94:   return validateTextModel(element, type, schema)
                     95: 
                     96: def validateText(text, type, schema):
1.41      ht         97:   if isinstance(type,XMLSchema.SimpleType):
                     98:     if type==XMLSchema.urType:
1.33      ht         99:       return
                    100:     else:
                    101:       return type.primitiveType.checkString(text)
                    102:   else:
                    103:     return type.checkString(text)
1.2       ht        104: 
1.9       ht        105: def assignAttributeTypes(element, attrdefs, extendable, schema):
1.2       ht        106:   # look up each attribute in attrdefs and assign its type
                    107:   # error if attr declaration is not found and type is not extendable
1.15      richard   108: #  print "assigning attrs for %s {%s}%s" % (element.name, element.uri, element.local)
1.33      ht        109:   element.attrTable={}
1.9       ht        110:   for a in element.attrs.values():
1.15      richard   111: #    print "assigning attr %s {%s}%s" % (a.name, a.uri, a.local)
1.41      ht        112:     an=XMLSchema.QName(None,a.local,a.uri)
1.33      ht        113:     element.attrTable[an]=a
1.27      richard   114:     if a.uri == xsi:
1.43      ht        115:       if a.local not in ('type','null','schemaLocation','noNamespaceSchemaLocation'):
1.33      ht        116:         verror(element,"unknown xsi attribute %s" % an,schema)
1.27      richard   117:     elif attrdefs.has_key(an):
1.43      ht        118:       a.type = attrdefs[an].attributeDeclaration
                    119:     elif (attrdefs.has_key("#any") and
                    120:           attrdefs["#any"].attributeDeclaration.allows(a.uri)):
                    121:       a.type = attrdefs["#any"].attributeDeclaration
1.2       ht        122:     else:
1.33      ht        123:       verror(element,"undeclared attribute %s" % an,schema)
1.2       ht        124:       a.type = None
1.33      ht        125:   return
1.2       ht        126: 
1.33      ht        127: def validateAttributeTypes(element,attrs, attrdefs, schema):
1.2       ht        128:   # check that each attribute matches its type
                    129:   # check that all required attributes are present
                    130:   # add defaulted attributes (shouldn't need to check their types)
1.33      ht        131:   for (adq,ad) in attrdefs.items():
                    132:     if ad.minOccurs==1 and not attrs.has_key(adq):
                    133:       verror(element,"required attribute %s not present"%adq,schema)
                    134:   for (an,a) in attrs.items():
                    135:     if an.uri!=xsi and a.type:
1.43      ht        136:       if isinstance(a.type,XMLSchema.Wildcard):
                    137:         res=a.type.validate(a,schema,'attribute',element)
                    138:       else:
                    139:         res=validateText(a.value,a.type.typeDefinition,
                    140:                          schema)
1.33      ht        141:       if res:
                    142:         verror(element,"attribute type check failed for %s: %s%s"%(an,
                    143:                                                                    a.value,
                    144:                                                                    res),
                    145:                schema)
1.2       ht        146: 
                    147: def assignChildTypes(children, elementTable, extendable, schema):
                    148:   # look up each child tag and record the type
                    149:   # (it may not be an error if it is not declared; we don't know that
                    150:   #  until we see what it matches in the content model)
                    151:   for child in children:
                    152:     if child.__class__ == Element:
1.41      ht        153:       qname = XMLSchema.QName(None,child.local,child.uri)
1.10      richard   154:       if elementTable.has_key(qname):
                    155:        child.type = elementTable[qname][1]
1.2       ht        156:       else:
                    157:        child.type = None
                    158:   return 1
                    159: 
                    160: def validateContentModel(element, type, schema):
                    161:   # trace a path through the content model
                    162:   # if a child matches an <any tag=... type=...> we need to indicate
                    163:   # that that child should be validated with its xsd:type if it has one
                    164:   # if a child matches some other kind of <any> we need to indicate
                    165:   # that it's not an error if we can't find its type
                    166: 
1.4       richard   167: #  print "validating model for %s content %s" % (element.name, type.content)
1.33      ht        168:   if type.contentType == "empty":
                    169:     validateEmptyModel(element, type, schema)
                    170:   elif type.contentType == "textOnly":
                    171:     validateTextModel(element, type.model, schema)
                    172:   else:
                    173:     validateElementModel(element, type.fsm,
                    174:                          type.contentType == "mixed", schema)
1.2       ht        175: 
                    176: def validateEmptyModel(element, type, schema):
                    177:   if len(element.children) != 0:
1.33      ht        178:     verror(element,"element %s must be empty but is not" % element.name,schema)
1.2       ht        179: 
                    180: def validateTextModel(element, type, schema):
                    181:   # check that:
                    182:   #   it has one pcdata child, and if so
                    183:   #     the text of the pcdata matches the type
                    184:   name = element.name
                    185:   n = len(element.children)
                    186:   if n > 1:
1.46      ht        187:     verror(element,"element {%s}%s with simple type not allowed %s (> 1) children" % (element.uri, name, n),schema)
1.33      ht        188:     return
1.2       ht        189:   elif n > 0 and element.children[0].__class__ != Pcdata:
1.46      ht        190:     verror(element,"element {%s}%s with simple type not allowed non-text children" % (element.uri,name),schema)
1.33      ht        191:     return
1.2       ht        192:   else:
                    193:     if n == 0:
                    194:       text = ""
                    195:     else:
                    196:       text = element.children[0].value
1.33      ht        197:     res=validateText(text, type, schema)
                    198:     if res:
                    199:       verror(element,"element content failed type check: %s%s"%(text,res),
                    200:              schema)
1.2       ht        201: 
1.4       richard   202: def validateElementModel(element, fsm, mixed, schema):
1.33      ht        203:   #  print "validating element model for %s" % element.name
1.4       richard   204:   n = fsm.startNode
                    205:   for c in element.children:
                    206:     if c.__class__ == Pcdata:
1.19      ht        207:       if (not mixed) and (not whitespace.match(c.value)):
1.33      ht        208:        verror(c,"text not allowed in element %s: |%s|" % (element.name,c.value),schema)
                    209:        return
1.4       richard   210:     elif c.__class__ == Element:
1.41      ht        211:       qname = XMLSchema.QName(None, c.local, c.uri)
1.8       richard   212:       next = None
1.13      richard   213:       anynext = None
1.4       richard   214:       for e in n.edges:
1.10      richard   215:         if e.label == qname:
1.8       richard   216:          next = e.dest
1.4       richard   217:          break
1.43      ht        218:         if isinstance(e.label, XMLSchema.Wildcard):
1.41      ht        219:           if e.label.allows(c.uri):
                    220:             anynext = e.dest
                    221:             anylab = e.label
1.8       richard   222:       if not next:
1.13      richard   223:         if anynext:
                    224:           n = anynext
1.17      richard   225: # this is no longer an error, but something more complicated is XXX
                    226: #          if c.type:
                    227: #            where(child.where)
                    228: #            print "element matched <any> but had a type assigned"
                    229: #            v = 0
                    230: #          else:
                    231: #            c.type = "<any>"
1.33      ht        232:           c.type = anylab
1.13      richard   233:         else:
1.41      ht        234:           verror(c,"element %s not allowed here in element %s" % (qname, XMLSchema.QName(None,element.local,element.uri)),schema)
1.33      ht        235:           fsm.printme(sys.stderr)
1.13      richard   236:       else:
                    237:         n = next
1.4       richard   238:   if not n.isEndNode:
1.33      ht        239:     verror(element,"content of %s is not allowed to end here" % element.name,
                    240:            schema,1)
                    241:     fsm.printme(sys.stderr)
                    242:   return
1.2       ht        243: 
                    244: def validateChildTypes(children, schema):
                    245:   # validate each child element against its type, if we know it
                    246:   # report an error if we don't know it and it's not in <any>
1.7       richard   247:   v = 1
1.2       ht        248:   for child in children:
                    249:     if child.__class__ == Element:
1.33      ht        250:       if child.type:
1.43      ht        251:         child.type.validate(child,schema,'element',child)
1.2       ht        252:       else:
1.33      ht        253:        verror(child,
1.41      ht        254:                "undeclared element %s" % XMLSchema.QName(None,child.local,child.uri),
1.33      ht        255:                schema)
1.2       ht        256: 
1.21      ht        257: def validateKeys(decl,elt):
1.22      ht        258:   elt.keyTabs={}
1.33      ht        259:   validateKeys1(elt,decl.keys,1)
                    260:   validateKeys1(elt,decl.uniques,0)
                    261:   validateKeyRefs(elt,decl.keyrefs)
1.22      ht        262: 
                    263: def validateKeys1(elt,kds,reqd):
                    264:   for key in kds:
1.21      ht        265:     tab={}
                    266:     sp=xpath.XPath(key.selector)
1.24      ht        267:     candidates=sp.find(elt)
1.21      ht        268:     if candidates:
                    269:       fps=map(lambda f:xpath.XPath(f),key.field)
                    270:       for s in candidates:
1.22      ht        271:         keyKey=buildKey(s,fps)
                    272:         if reqd and not keyKey:
1.33      ht        273:           verror(s,
                    274:                  "missing one or more fields %s from key %s"%(key.field,
                    275:                                                               key.name),
                    276:                  schema)
1.22      ht        277:           break
1.21      ht        278:        if len(keyKey)>1:
                    279:          keyKey=tuple(keyKey)
                    280:        else:
                    281:          keyKey=keyKey[0]
                    282:        if tab.has_key(keyKey):
1.33      ht        283:          verror(s,"duplicate key %s, first appearance was"%str(keyKey),
                    284:                  key.schema)
1.43      ht        285:          XMLSchema.where(tab[keyKey].where)
1.21      ht        286:        else:
                    287:          tab[keyKey]=s
1.22      ht        288:     elt.keyTabs[key.name]=tab
                    289: 
                    290: def buildKey(s,fps):
                    291:   keyKey=[]
                    292:   for fp in fps:
1.24      ht        293:     kv=fp.find(s)
1.22      ht        294:     if kv:
                    295:       if len(kv)>1:
1.33      ht        296:         vwarn(s,"oops, multiple field hits for %s at %s: %s"%(fp.str,s,kv))
1.22      ht        297:       if isinstance(kv[0],Element):
                    298:         if (len(kv[0].children)>0 and
                    299:             isinstance(kv[0].children[0],Pcdata)):
                    300:           keyKey.append(kv[0].children[0].value)
                    301:         else:
                    302:           # XPath says in this case value is the empty string
                    303:           pass
                    304:       elif type(kv[0])==types.StringType:
                    305:         keyKey.append(kv[0])
                    306:       else:
1.33      ht        307:         vwarn(s,"oops, key value %s:%s"%(type(kv[0]),kv[0]))
1.22      ht        308:     else:
                    309:       return None
                    310:   return keyKey
                    311: 
                    312: def validateKeyRefs(elt,krds):
                    313:   res=1
                    314:   for ref in krds:
1.25      ht        315:     if elt.keyTabs.has_key(ref.refer):
                    316:       keyTab=elt.keyTabs[ref.refer]
                    317:       if keyTab=='bogus':
                    318:        break
                    319:     else:
                    320:       elt.keyTabs[ref.refer]='bogus'
1.33      ht        321:       verror(ref.elt,
                    322:              "No key or unique constraint named %s declared, refed by keyref %s"%(ref.refer,ref.name),
                    323:              ref.schema)
1.25      ht        324:       break
1.22      ht        325:     sp=xpath.XPath(ref.selector)
1.24      ht        326:     candidates=sp.find(elt)
1.22      ht        327:     if candidates:
                    328:       fps=map(lambda f:xpath.XPath(f),ref.field)
                    329:       for s in candidates:
                    330:         keyKey=buildKey(s,fps)
                    331:         if not keyKey:
                    332:           break
                    333:        if len(keyKey)>1:
                    334:          keyKey=tuple(keyKey)
                    335:        else:
                    336:          keyKey=keyKey[0]
1.25      ht        337:        if not keyTab.has_key(keyKey):
1.33      ht        338:          verror(s,"no key in %s for %s"%(ref.refer,str(keyKey)),ref.schema)
1.21      ht        339: 
1.30      richard   340: def findSchemaLocs(element):
                    341:   pairs = []
                    342:   for a in element.attrs.values():
1.43      ht        343:     if a.uri == xsi:
                    344:       if a.local == "schemaLocation":
                    345:         scls=string.split(a.value)
                    346:         while scls:
                    347:           pairs.append((scls[0], scls[1]))
                    348:           scls=scls[2:]
                    349:       elif a.local == "noNamespaceSchemaLocation":
                    350:         pairs.append(None,a.value)
1.30      richard   351:   for c in element.children:
                    352:     if isinstance(c, Element):
1.43      ht        353:       scl=findSchemaLocs(c)
                    354:       if scl:
                    355:         pairs = pairs + scl
1.30      richard   356:   return pairs
                    357:   
1.37      ht        358: def runit(en,rns=[],k=0):
1.21      ht        359:   global s,e,t
1.33      ht        360: 
1.45      ht        361:   ss = s = None
1.33      ht        362: 
1.38      ht        363:   if rns:
                    364:     sys.stderr.write("%s: schema-validating %s using schemas %s\n"%(vs,en,rns))
                    365:   else:
                    366:     sys.stderr.write("%s: schema-validating %s\n"%(vs,en))
1.30      richard   367: 
1.41      ht        368:   f=XMLSchema.newFactory()
1.36      ht        369:   base=f.fileNames[0]
1.41      ht        370:   ren=XMLSchema.resolveURL(base,en)
1.30      richard   371: 
1.28      ht        372:   if rns:
1.41      ht        373:     s = XMLSchema.fromFile(XMLSchema.resolveURL(base,rns[0]),f)
1.30      richard   374:     for rn in rns[1:]:
1.45      ht        375:       ss=ss or XMLSchema.fromFile(XMLSchema.resolveURL(base,rn),f)
1.33      ht        376:   else:
1.43      ht        377:     s = XMLSchema.Schema(f,None)
1.33      ht        378:     s.targetNS='##dummy'
1.30      richard   379: 
1.45      ht        380:   if not s:
                    381:     s=ss
                    382: 
1.33      ht        383:   e=readXML(en)                         # error return?
                    384:   
1.30      richard   385:   schemaLocs = findSchemaLocs(e)
1.33      ht        386:   sys.stderr.write("schemaLocations from instance: %s\n" % schemaLocs)
1.30      richard   387:   for (ns, sl) in schemaLocs:
1.45      ht        388:     XMLSchema.checkinSchema(f, ns, sl,e,ren)
1.30      richard   389:   
1.34      ht        390:   if (e.uri and
                    391:       (e.uri not in ('http://www.w3.org/XML/1998/namespace',
                    392:                    'http://www.w3.org/1999/XMLSchema-instance')) and
                    393:       not f.schemas.has_key(e.uri)):
                    394:     try:
1.45      ht        395:       XMLSchema.checkinSchema(f,e.uri,e.uri,e,ren)
1.34      ht        396:       sys.stderr.write("no schema yet for %s, trying namespace URI itself. . ."%
                    397:                        e.uri)
                    398:       sys.stderr.write("ok.\n")
                    399:     except XMLinter.error:
                    400:       sys.stderr.write("no schema yet for %s, trying namespace URI itself. . ."%
                    401:                        e.uri)
                    402:       sys.stderr.write("failed.\n")
1.30      richard   403:     
1.41      ht        404:   ecount=XMLSchema.prepare(f)
1.33      ht        405:   
                    406:   if ecount:
                    407:     if k:
                    408:       km="continuing"
                    409:     else:
                    410:       km="stopping without validating instance"
                    411:     em="%d errors in schemas, %s"%(ecount,km)
                    412:     if not k:
                    413:       sys.stderr.write("%s\n"%em)
                    414:       return
                    415:   else:
                    416:     em="Schema(s) OK"
                    417:   sys.stderr.write("%s\n"%em)
1.30      richard   418: 
1.28      ht        419:   cl=string.find(':',e.name)
                    420:   if cl>-1:
                    421:     prefix=e.name[0:cl]
                    422:   else:
                    423:     prefix=''
1.41      ht        424:   eltname = XMLSchema.QName(prefix,e.local,e.uri)
1.30      richard   425: 
                    426:   if not s:
                    427:     # any one will do
1.33      ht        428:     s = f.sfors
                    429:   t=None
                    430:   
                    431:   if s and s.vElementTable.has_key(eltname):
                    432:     t=s.vElementTable[eltname].typeDefinition
                    433:   if not t:
                    434:     sys.stderr.write("can't validate, because can't find type for %s\n" % eltname)
                    435:     return
                    436: 
                    437:   if e and s:
                    438:     if t.name:
                    439:       sys.stderr.write("validating with type %s\n" % t.name)
                    440:     else:
                    441:       sys.stderr.write("validating with anonymous type\n")
                    442:     validate(e, t, s)
                    443:     if s.factory.errors:
                    444:       sys.stderr.write("%d validation errors\n" % s.factory.errors)
                    445:       return 1
                    446:     else:
                    447:       sys.stderr.write("No errors\n")
                    448:       return 0
1.30      richard   449: 
1.33      ht        450: def verror(elt,message,schema,two=0):
                    451:   sys.stderr.write("Validation error: ")
                    452:   if two:
1.41      ht        453:     XMLSchema.where(elt.where2)
1.33      ht        454:   else:
1.41      ht        455:     XMLSchema.where(elt.where)
1.33      ht        456:   sys.stderr.write(" ")
                    457:   sys.stderr.write(message)
                    458:   sys.stderr.write("\n")
                    459:   schema.factory.errors=schema.factory.errors+1
                    460: 
                    461: def vwarn(elt,message):
                    462:   sys.stderr.write("Validation warning: ")
                    463:   if elt:
1.43      ht        464:     XMLSchema.where(elt.where)
1.33      ht        465:   sys.stderr.write(message)
                    466:   sys.stderr.write("\n")
                    467: 
1.24      ht        468: 
1.41      ht        469: # validation methods for schema components
                    470: 
1.43      ht        471: def av(self,child,schema,kind,elt):
1.41      ht        472:   q = XMLSchema.QName(None,child.local,child.uri)
1.43      ht        473:   vwarn(elt,"allowing %s because it matched wildcard(%s)" %
                    474:         (q,self.allowed))
                    475:   if self.processContents!='skip':
1.41      ht        476:     if schema.factory.schemas.has_key(child.uri):
                    477:       # only try if we might win -- needs work
                    478:       try:
1.43      ht        479:         if kind=='element':
                    480:           e = schema.vElementTable[q]
                    481:         else:
                    482:           e = schema.vAttributeTable[q]
1.41      ht        483:       except KeyError:
                    484:         e=None
                    485:       if e:
1.43      ht        486:         vwarn(None,"validating it against %s" %
                    487:               (e.typeDefinition.name or 'anonymous type'))
                    488:         if kind=='element':
                    489:           validateElement(child, e.typeDefinition, schema)
                    490:         else:
                    491:           return validateText(a.value,e.typeDefinition,schema)
                    492:       elif self.processContents=='strict':
                    493:         verror(elt,
                    494:                "can't find a type for wildcard-matching %s %s" %(kind, q),
                    495:                schema)
                    496: 
                    497: XMLSchema.Wildcard.validate=av
1.42      ht        498: 
1.43      ht        499: def tv(self,child,schema,kind,elt):
1.42      ht        500:   validateElement(child, self, schema)
1.41      ht        501: 
1.43      ht        502: XMLSchema.Type.validate=XMLSchema.AbInitio.validate=tv
1.41      ht        503: 
1.42      ht        504: # run at import if top
                    505: 
                    506: if __name__=='__main__':
                    507:   argl=sys.argv[1:]
                    508:   k=0
                    509:   while argl:
                    510:     if argl[0]=='-k':
                    511:       k=1
                    512:     else:
                    513:       break
                    514:     argl=argl[1:]
                    515: 
                    516:   if argl:
                    517:     runit(argl[0],argl[1:],k)
                    518:   else:
                    519:     runit("tiny.xml",["tiny.xsd"],k)
1.41      ht        520: 
1.25      ht        521: # $Log: applyschema.py,v $
1.47    ! richard   522: #
        !           523: # Revision 1.48  2000/04/28 15:40:01  richard
        !           524: # Implement xsi:null (still don't check nullable)
1.46      ht        525: #
                    526: # Revision 1.47  2000/04/28 15:11:23  richard
                    527: # allow xsi: attributes on simple type
                    528: # moved eltDecl code up validateElement ready for implementing xsi:null
1.45      ht        529: #
                    530: # Revision 1.46  2000/04/27 09:41:18  ht
                    531: # remove raw types from error messages
1.44      ht        532: #
                    533: # Revision 1.45  2000/04/27 09:30:21  ht
                    534: # check that inputs are actually schemas,
                    535: # remove schema arg to doImport, checkInSchema
                    536: #
                    537: # Revision 1.44  2000/04/26 13:00:40  ht
1.43      ht        538: # add copyright
                    539: #
                    540: # Revision 1.43  2000/04/24 20:46:40  ht
1.42      ht        541: # cleanup residual bugs with massive rename,
                    542: # rename Any to Wildcard,
                    543: # replace AnyAttribute with Wildcard,
                    544: # get validation of Wildcard working in both element and attribute contexts
1.41      ht        545: #
                    546: # Revision 1.42  2000/04/24 15:08:34  ht
                    547: # minor glitches, tiny.xml works again
1.40      ht        548: #
                    549: # Revision 1.41  2000/04/24 15:00:09  ht
                    550: # wholesale name changes -- init. caps for all classes,
1.39      ht        551: # schema.py -> XMLSchema.py
                    552: #
                    553: # Revision 1.40  2000/04/24 11:09:17  ht
1.38      ht        554: # make version string universally available
                    555: #
                    556: # Revision 1.39  2000/04/24 10:06:59  ht
1.37      ht        557: # add version info to message
                    558: #
                    559: # Revision 1.38  2000/04/24 10:02:39  ht
                    560: # change invocation message
1.36      ht        561: #
                    562: # Revision 1.37  2000/04/24 09:41:43  ht
                    563: # clean up invocation some more, add k arg't to runit
1.35      ht        564: #
                    565: # Revision 1.36  2000/04/21 09:32:21  ht
                    566: # another dose of resolveURL
1.34      ht        567: # use tiny only if run from command line
                    568: #
                    569: # Revision 1.35  2000/04/20 22:12:43  ht
1.33      ht        570: # use resolveURL on input, schemaLocs
                    571: #
                    572: # Revision 1.34  2000/04/20 15:45:08  ht
                    573: # better handling of use of ns uri for loc
                    574: #
                    575: # Revision 1.33  2000/04/20 14:26:59  ht
                    576: # merge in private and comp branches
                    577: #
                    578: # Revision 1.32.2.5  2000/04/20 14:25:54  ht
                    579: # merge in comp branch
                    580: #
                    581: # Revision 1.32.2.4.2.9  2000/04/20 14:22:39  ht
                    582: # manage document validation schema creation and search better
                    583: #
                    584: # Revision 1.32.2.4.2.8  2000/04/20 12:03:21  ht
                    585: # Remove a few lingering effectiveTypes
                    586: # Allow better for absent types etc.
                    587: #
                    588: # Revision 1.32.2.4.2.7  2000/04/14 21:18:27  ht
                    589: # minor attr names/path changes to track schema
                    590: #
                    591: # Revision 1.32.2.4.2.6  2000/04/13 23:04:39  ht
                    592: # allow for urType as simple type (?)
                    593: # track Any->AnyWrap change
                    594: #
                    595: # Revision 1.32.2.4.2.5  2000/04/12 17:29:37  ht
                    596: # begin work on model merger,
                    597: #
                    598: # Revision 1.32.2.4.2.4  2000/04/11 18:13:17  ht
                    599: # interpolate attributeUse between complexType and attributeDeclaration,
                    600: # parallel to particle
                    601: #
                    602: # Revision 1.32.2.4.2.3  2000/04/10 15:48:46  ht
                    603: # put modest attribute validation in place
                    604: #
                    605: # Revision 1.32.2.4.2.2  2000/04/09 16:13:26  ht
                    606: # working on complex type, attribute;
                    607: # back out component.qname
                    608: #
                    609: # Revision 1.32.2.4.2.1  2000/04/05 12:12:36  ht
                    610: # accommodate changes in schema.py
                    611: #
                    612: # Revision 1.32.2.4  2000/04/01 18:01:25  ht
                    613: # various minor compatibility fixes
                    614: #
                    615: # Revision 1.32.2.3  2000/03/25 12:12:27  ht
                    616: # restructure error handling/reporting;
                    617: # allow for switching 208 on and off
                    618: #
                    619: # Revision 1.32.2.2  2000/03/21 15:57:23  ht
                    620: # fix bug in skip,
1.32      ht        621: # allow 208 override
                    622: #
                    623: # Revision 1.32.2.1  2000/03/20 17:22:52  ht
                    624: # better coverage of <any>, including beginning of processcontents
                    625: #
                    626: # Revision 1.33  2000/03/20 17:20:53  ht
                    627: # better coverage of <any>, including beginning of processcontents
                    628: #
                    629: # Revision 1.32  2000/03/08 15:28:46  ht
                    630: # merge private branches back into public after 20000225 release
                    631: #
                    632: # Revision 1.31.2.3  2000/02/24 23:40:32  ht
                    633: # fix any bug
                    634: #
                    635: # Revision 1.31.2.2  2000/02/21 09:18:13  ht
                    636: # bug in <any> handling
                    637: #
1.31      richard   638: # Revision 1.31.2.1  2000/02/08 21:43:39  ht
                    639: # fork private branch to track internal drafts
                    640: # change calling sequence of checkinSchema
1.30      richard   641: #
                    642: # Revision 1.31.1.1  2000/02/08 13:54:25  ht
                    643: # fork branch for non-public changes
1.29      ht        644: # calling sequence to checkinSchema changed
                    645: #
                    646: # Revision 1.31  2000/01/13 16:55:42  richard
                    647: # Finally do something with xsi:type
1.28      ht        648: #
                    649: # Revision 1.30  2000/01/10 17:36:34  richard
                    650: # changes for xsi:schemaLocation
1.27      richard   651: #
                    652: # Revision 1.29  2000/01/08 23:33:50  ht
                    653: # towards support for xsi:schemaLocation
1.26      ht        654: #
                    655: # Revision 1.28  2000/01/08 12:07:38  ht
                    656: # Change command-line arg sequence in preparation for use of schemaLocation!!!!!
1.25      ht        657: # Add debug printout for schemaLocation for now
                    658: #
                    659: # Revision 1.27  2000/01/07 17:08:26  richard
                    660: # start on xsi:type
                    661: #
1.24      ht        662: # Revision 1.26  2000/01/06 14:59:38  ht
1.1       ht        663: # fix command line bug, display args on entry
                    664: #
                    665: # Revision 1.25  2000/01/06 14:38:56  ht
                    666: # detect cross-scope keyref and signal error
                    667: #
                    668: # Revision 1.24  2000/01/03 17:02:37  ht
                    669: # Include result of sub-ordinate key checking in overall result
                    670: # Accommodate new calling sequence for xpath.find
                    671: # add Log and Id
                    672: #
                    673: #

Webmaster