The dip.io.codecs.xml module implements support for XML encoders and decoders used with streaming storage.
Base class: Model
The XmlCodec class implements a codec that decodes and encodes instances of Model as XML. The codec does not set the format attribute. This should be defined in a sub-class or passed as an argument when the codec is created.
A model is decoded from a byte stream.
Parameters: |
|
---|---|
Returns: | the decoded model. This may be the original model populated from the storage location, or it may be a different model (of an appropriate type) created from the storage location. |
A model is encoded as a byte stream.
Parameters: |
|
---|---|
Returns: | a generator that will return sections of the encoded byte stream. |
Base class: Model
The XmlDecoder class implements a model decoder that decodes a Model instance from XML.
A model is decoded from an XML byte stream.
Parameters: |
|
---|---|
Returns: | the decoded model. |
Decode the current element as an attribute.
Parameters: |
|
---|
Decode the document element (i.e. the outermost element).
Parameters: |
|
---|
Decode the next element as a model.
Parameters: |
|
---|
Base class: Model
The XmlEncoder class implements a model encoder that encodes a Model instance as XML.
Note that, by default, pickle is used to encode any attributes that don’t have a value corresponding to a fundamental Python type (i.e. Int, List etc.). It is recommended (but not required) that the model is defined fully in terms of these fundamental types or that the encoder is sub-classed to handle attributes with non-fundamental types explicitly.
A model is encoded as an XML byte stream.
Parameters: |
|
---|---|
Returns: | the next section of the encoded XML byte stream. |
A single attribute is encoded as an XML byte stream.
Parameters: |
|
---|---|
Returns: | the next section of the encoded XML byte stream. |
A model is encoded as an XML byte stream.
Parameters: |
|
---|
Replace any characters with their corresponding entities.
Parameter: | value – is the string to escape. |
---|---|
Returns: | the escaped string. |
Return a string that will indent a line to a particular level.
Parameter: | indent_level – is the indentation level as a number. |
---|---|
Returns: | the string. |