示例#1
0
 def init(self,elt):
   if self.restriction is not None:
     self.sub=self.restriction
   elif self.extension is not None:
     self.sub=self.extension
   else:
     shouldnt('cecm')
示例#2
0
文件: driver.py 项目: vimov/Deployer
def dumpInfoset(fileOrName,reflect,factory,independent=0,control=2):
  if independent:
    if reflect==2:
      shouldnt("ind reflection of instance")
    r=Document(None)
    e=Element(r,psviSchemaNamespace,"schema")
    r.addChild(e)
    si=collectSchemaInfo(factory,1)
    indNorm.reflect.assignAllUIDs(si)
    indNorm.reflect.reflectAllComponents(e,si)
    e.inScopeNamespaces["i"]=Namespace("i", xsi)
    e.inScopeNamespaces["x"]=Namespace("x", XMLSchemaNS)
    e.inScopeNamespaces[None]=Namespace(None, infosetSchemaNamespace)
  elif factory.docElt is None:
    # fatal schema errors, can't reflect yet
    return
  else:
    r = factory.docElt.parent.reflect(None,control)
  close=0
  r.documentElement.inScopeNamespaces["p"]=Namespace("p",
                                                     psviSchemaNamespace)
  if type(fileOrName) is types.FileType:
    ff=fileOrName
  else:
    close=1
    ff = open(fileOrName, "w")
  r.indent("",1)
  ffu=codecs.getwriter('utf8')(ff)
  r.printme(ffu)
  if close:
    ffu.close()
  else:
    ffu.reset()
示例#3
0
  def merge(self,other):
    # called in content model restricting
    shouldnt('merge3')
    myName=self.name or self.ref
    if other.__class__==Element:
      otherName=other.name or other.ref
      if myName==otherName:
	# should do subsumption check, construct merged type, of course
	return self
      else:
	self.error("can't restrict %s with %s"%(otherName,myName))
示例#4
0
文件: reflect.py 项目: vimov/Deployer
def facetsReflect(self,parent):
  if self.variety=='atomic':
    auth=self.primitiveType
  elif self.variety=='list':
    auth=List
  elif self.variety=='union':
    auth=Union
  else:
    shouldnt('bogusv: %s'%self.variety)
  for fn in auth.allowedFacets:
    if self.facets.has_key(fn):
      facet=self.facets[fn]
    else:
      facet=None
    if (facet is not None and facet.value is not None):
      fval=facet.value
      if type(fval)==types.ListType:
        if fn=='pattern':               # hack to save megaspace
          if facet.uids is not None:
            # a pointer
            for uid in facet.uids:
              facet.reflectAsPointer(uid,parent)
          else:
            if facet.uids is None:
              facet.id=facet.fid
              facet.assignUid()
              n=1
              facet.uids=[]
              for vl in fval:
                if vl in builtinPats:
                  nuid="bip..%d"%builtinPats.index(vl)
                  facet.reflectAsPointer(nuid,parent)
                else:
                  f=facetReflect(parent,fn,vl)
                  nuid="%s..%d"%(facet.uid,n)
                  idAttr = XMLInfoset.Attribute(f, None, "id", None, nuid)
                  f.addAttribute(idAttr)
                facet.uids.append(nuid)
                n=n+1
        else:
          for vl in fval:
            f=facetReflect(parent,fn,vl)
      else:
        f=facetReflect(parent,fn,fval)
        f.reflectBoolean(f,"fixed",facet.fixed,0)
      if facet.annotation is not None:
        # note hack for list-vals -- annotation on last one
        facet.annotation.reflect(f)