Ejemplo n.º 1
0
def cloneObject(objectToClone,
                knownTypes=None,
                marshalType=True,
                knownNamespaces=None,
                encoding='utf-8'):
    if (knownTypes == None):
        knownTypes, knownNamespaces = getAgKnownTypes()
    xml = xmlmarshaller.marshal(objectToClone,
                                prettyPrint=True,
                                marshalType=marshalType,
                                knownTypes=knownTypes,
                                knownNamespaces=knownNamespaces,
                                encoding=encoding)
    clonedObject = xmlmarshaller.unmarshal(xml,
                                           knownTypes=knownTypes,
                                           knownNamespaces=knownNamespaces)
    if hasattr(objectToClone, 'fileName'):
        clonedObject.fileName = objectToClone.fileName
    if hasattr(objectToClone, "_parentDoc"):
        clonedObject._parentDoc = objectToClone._parentDoc
    try:
        clonedObject.initialize()
    except AttributeError:
        pass
    return clonedObject
Ejemplo n.º 2
0
def unmarshal(xml,
              knownTypes=None,
              knownNamespaces=None,
              xmlSource=None,
              createGenerics=False):
    if (knownTypes == None):
        knownTypes, knownNamespaces = getAgKnownTypes()
    return xmlmarshaller.unmarshal(xml,
                                   knownTypes=knownTypes,
                                   knownNamespaces=knownNamespaces,
                                   xmlSource=xmlSource,
                                   createGenerics=createGenerics)
Ejemplo n.º 3
0
def cloneObject(objectToClone, knownTypes=None, marshalType=True, knownNamespaces=None, encoding='utf-8'):
    if (knownTypes == None): 
        knownTypes, knownNamespaces = getAgKnownTypes()
    xml = xmlmarshaller.marshal(objectToClone, prettyPrint=True, marshalType=marshalType, knownTypes=knownTypes, knownNamespaces=knownNamespaces, encoding=encoding)
    clonedObject = xmlmarshaller.unmarshal(xml, knownTypes=knownTypes, knownNamespaces=knownNamespaces)
    if hasattr(objectToClone, 'fileName'):
        clonedObject.fileName = objectToClone.fileName
    if hasattr(objectToClone, "_parentDoc"):
        clonedObject._parentDoc = objectToClone._parentDoc
    try:
        clonedObject.initialize()
    except AttributeError:
        pass
    return clonedObject
Ejemplo n.º 4
0
def unmarshal(xml, knownTypes=None, knownNamespaces=None, xmlSource=None, createGenerics=False):
    if (knownTypes == None): 
        knownTypes, knownNamespaces = getAgKnownTypes()
    return xmlmarshaller.unmarshal(xml, knownTypes=knownTypes, knownNamespaces=knownNamespaces, xmlSource=xmlSource, createGenerics=createGenerics)