ePages 6.11.0 - DE_EPAGES/Object/API/XML/ObjectExportDriver.pm

Package DE_EPAGES::Object::API::XML::ObjectExportDriver

This module implements a SAX2 driver to export object type(s) Object, Attribute, Class.

Base
DE_EPAGES::XML::API::BaseExportDriver
Example
use DE_EPAGES::Object::API::XML::ObjectExportDriver qw( ExportObjects );
ExportObjects( '/Shops', '/tmp/shops.xml', { encoding => 'utf-8' }, ['DemoShop', 'MyShop'] );
@EXPORT_OK
ExportObjects

Functions

ExportObjects
addNextLevelItem
addObject
addObjectReference
drive
existsNextLevelItems
exportDefaults
exportLevel
nextLevelItem
nextLevelItems
removeNextLevelItem
resetNextLevelItems
tagName
xmlParentObject

ExportObjects

Exports object (based on DE_EPAGES::Object::API::BaseObject) into a file with given encoding

Syntax
ExportObjects( $Path, $FileName, $hParams, $aObjects, $Transform );
Example
ExportObjects( '/Shops/DemoShop', 'Products.xml', {}, [ 'Products' ] );
Input
$Path (string)
path of root of objects
$FileName (string)
name of export file
$hParams (ref.hash)
parameter keys:
  • encoding | encoding string (default utf-8)(optional)| Encoding
  • recursive | export Objects recursive ? (optional, default 1) | Boolean
  • withdefaults | export also defaults (optional, default 0)| Boolean
  • writer | your own xml writer package (optional)| String
$Objects (ref.array.string)
list of path strings
$Transform (ref.code)
transformer function (optional)

addNextLevelItem

Adds an object to be processed next time again, because it has references to object, which are not processed yet.

Syntax
$self->addNextLevelItem($Object, $Level);
Input
$Object (object)
object to export
$Level (integer)
export level (default is current + 1)

addObject

adds an XML element (based on a BaseObject) to the SAX2 stream. calls $self->$TagName to retrieve the attributes of the element. executes registered hook functions to create sub elements. The function addHook is used to register such hook functions.

Syntax
$self->addObject( $TagName, $Object );
Example
$self->addObject( 'Company', $Company );
Input
$TagName (string)
element name
$Object (object)
Object

addObjectReference

adds an XML element (based on a BaseObject) to the SAX2 stream.

Syntax
$self->addObjectReference( $TagName, $Object, $hAttributes );
Example
$self->addObjectReference( 'Company', $Company );
Input
$TagName (string)
element name
$Object (object)
Object
$hAttributes (ref.hash.string)
additional xml attributes

drive

Runs through the objects and writes the xml content.

Syntax
$self->drive;

existsNextLevelItems

Returns if objects existing which should be processed next time.

Syntax
$self->existsNextLevelItems($Level);
Input
$Level (integer)
export level (default is current + 1)

exportDefaults

The exporter can decide, if attribute values which are equal to the default values of an class, will be exported or not.

Syntax
$ExportDefault = $self->exportDefaults;
Return
$ExportDefault (boolean)
include values ( which equal to default) in exportfile

exportLevel

In case of objects, which references multible other object (like cross selling) it nessecary that the export runs multiple times. To add objects for the next export run use addNextLevelItem.

Syntax
$ExportLevel = $self->exportLevel;
Return
$ExportLevel (integer)
exporter runs the xxx time

nextLevelItem

Adds an object to be processed next time again, because it has references to object, which are not processed yet.

Syntax
$Object = $self->nextLevelItem($Level);
Input
$Level (integer)
export level (default is current)
Return
$Object (object)
object to export

nextLevelItems

Returns all objects which should be processed.

Syntax
$self->nextLevelItems;

removeNextLevelItem

Adds an object to be processed next time again, because it has references to object, which are not processed yet.

Syntax
$self->removeNextLevelItem($Object, $Level);
Input
$Object (object)
object to export
$Level (integer)
export level (default is current)

resetNextLevelItems

Resets the object which should be processed next time.

Syntax
$self->resetNextLevelItems;

tagName

The importer uses the TagName to find the Class of the object. Its is sometimes not possible to use the tag for the class (eg. for Products) because the class name is not unique.

Syntax
$TagName = $self->tagName;
Return
$ExportDefault (boolean)
include values ( which equal to default) in exportfile

xmlParentObject

if an xml element is processed, this function return the object of the outer xml element. This is used to resolve relative objects paths in the current xml element.

Syntax
$Object = $self->xmlParentObject;
Return
$Object (object)
Object