ePages 6.10 - DE_EPAGES/Object/API/Object/XMLStructure.pm

Package DE_EPAGES::Object::API::Object::XMLStructure

logical structure presenting an xml file that contains database content. the structure contains a lot of elements that are referenced by object path. every xml element has a lot of semantic structure attributes e.g. xml-file:

  • /Classes/object/sub1/sub2
  • /Classes/object/sub1/sub2/AttributeValue{Language->de;Name->Name}
  • /Classes/Product
  • /Classes/Product/Form{Name->Save}
  • /Classes/Product/Form{Name->Save}/FormField{Name->EnableAllShippingMethods} if changes where made please actualize: http://ep-support.intern.epages.de:8080/wiki/index.php/Image:XMLStructure.jpeg http://ep-support.intern.epages.de:8080/wiki/index.php/XML_Structure

    Functions

    addElement
    assimilateXMLStructure
    countTagAttributes
    deleteChilds
    deleteElement
    deleteTagAttribute
    deleteTagAttributes
    deleteXMLStructAttribute
    existsAdditionalTagAttributes
    existsElement
    existsIDPart
    existsParentElement
    existsSubElement
    existsTagAttribute
    existsXMLStructAttribute
    getChildElements
    getClass
    getDirectChildElements
    getElements
    getElementsWithoutParent
    getID
    getIDValue
    getRootElements
    getTagAttribute
    getTagAttributes
    getTagAttributesHash
    getXMLStructAttribute
    getXMLStructAttributes
    getXMLStructAttributesHash
    getXMLType
    getXMLTypeAddictedID
    isEmpty
    isRootElement
    new
    parentElement
    setID
    setTagAttribute
    setTagAttributes
    setXMLStructAttribute
    setXMLStructAttributes

    addElement

    adds a new element to the semantic structure.

    Syntax
    $XMLStruct->addElement($ElementName,$Class,$hID, $hXMLStructAttributes,$hTagAttributes);
    Example
    $self->addElement('/Class/Class1/Objects/Object1/Attributes/TranslationAttribute{Language->de;Name->Test}',
        'TranslationAttribute',
        {'Language' => 'de', 'Name' => 'Test'},
        {'TagName' => 'Attribute'},
        {'Meta' => 'Übersetzung', 'delete' => '1' }
    );
    Input
    $ElementName (string)
    name of element in semantic structure
    $Class (string)
    class of given element
    $hID (ref.hash.string)
    key value pairs of semantic structure identifier
    $hXMLStructAttributes (ref.hash.string)
    key value pairs of semantic structure attributes
    $hTagAttributes (ref.hash.string)
    key value pairs of tag attributes

    assimilateXMLStructure

    added all elements and attributes from alien semantic structure taht dont exists if 'overwrite' is set to '1' additional all attributes that exists in both will overwrite by the alien semantic structure.

    Syntax
    $XMLStruct->assimilateXMLStructure($AlienXMLStruct, $hOptions);
    Example
    $XMLStruct->assimilateXMLStructure($XMLStruct2, {'overwrite' => '1'});
    Input
    $AlienXMLStruct (semantic structure object)
    semantic structure that should be assimilate
    $hOptions (ref.hash)
    {'overwrite' => '1'} keys already exists will be overwrite

    countTagAttributes

    return the number of tag attribute, from element

    Syntax
    my $CountTagAttributes = $XMLStruct->countTagAttributes($ElementName);
    Input
    $ElementName (string)
    name of element in semantic structure
    Return
    $CountTagAttributes (int)
    value of tag attribute in elment

    deleteChilds

    delete all child elements of given element.

    Syntax
    $XMLStruct->deleteChilds($Element);
    Input
    $Element (string)
    name of element in semantic structure

    deleteElement

    removes an element with given path from semantic structure.

    Syntax
    $XMLStruct->deleteElement($ElementName);
    Input
    $ElementName (string)
    name of element in semantic structure

    deleteTagAttribute

    delete the attribute of element in semantic structure

    Syntax
    $XMLStruct->deleteTagAttribute($ElementName, $TagAttributeName);
    Input
    $ElementName (string)
    name of element in semantic structure
    $TagAttributeName (string)
    name of tag attribute in semantic structure

    deleteTagAttributes

    delete all attributes of element in semantic structure

    Syntax
    $XMLStruct->deleteTagAttributes($ElementName);
    Input
    $ElementName (string)
    name of element in semantic structure

    deleteXMLStructAttribute

    delete the attribute of element in semantic structure

    Syntax
    $XMLStruct->deleteXMLStructAttribute($ElementName, $XMLStructAttributeName);
    Input
    $ElementName (string)
    name of element in semantic structure
    $XMLStructAttributeName (string)
    name of semantic structe attribute

    existsAdditionalTagAttributes

    return true if additionally attributes exists besides the attributes in array. return false if only the given attributes exists.

    Syntax
    my $Exists = $XMLStruct->existsAdditionalTagAttributes($ElementName,$aControlAttributeNames);
    Input
    $ElementName (string)
    name of element in semantic structure
    $aControlAttributeNames (ref.array)
    ref of array with attribute names that have to check
    Return
    $Exists (bool)
    false if only given attributes exists

    existsElement

    return true if the path of an element exists in the semantic structure.

    Syntax
    my $ExistsElement = $XMLStruct->existsElement($ElementName);
    Input
    $ElementName (string)
    name of element in semantic structure
    Return
    $ExistsElement (bool)
    true if name (path) of element exists

    existsIDPart

    return true if part of id for element exists

    Syntax
    my $Exists = $XMLStruct->existsIDPart($ElementName,$IDName);
    Input
    $ElementName (string)
    name of element in semantic structure
    Return
    $Exists (bool)
    true if exists identifier name for given element

    existsParentElement

    return true if the parent path of an element is an element of the semantic structure.

    Syntax
    my $ExistsParentElement = $XMLStruct->existsParentElement($ElementName);
    Input
    $ElementName (string)
    name of element in semantic structure
    Return
    $ExistsParentElement (bool)
    true if name (path) of element exists

    existsSubElement

    return true if one ore more sub elements of given element exists

    Syntax
    my $SubElementExists = $XMLStruct->existsSubElement($ElementName);
    Input
    $ElementName (string)
    name of element in semantic structure
    Return
    $SubElementExists (bool)
    true if a sub element exists

    existsTagAttribute

    return true if if the attribute of element exists

    Syntax
    my $ExistsTagAttribute = $XMLStruct->existsTagAttribute($ElementName, $TagAttributeName);
    Input
    $ElementName (string)
    name of element in semantic structure
    $TagAttributeName (string)
    name of tag attribute in semantic structure
    Return
    $ExistsTagAttribute (bool)
    true if attribute of element exists

    existsXMLStructAttribute

    return true if semantic structure element exists for given element

    Syntax
    my $Exists = $XMLStruct->existsXMLStructAttribute($ElementName, $XMLStructAttributeName);
    Input
    $ElementName (string)
    name of element in semantic structure
    $XMLStructAttributeName (string)
    name of semantic structure attribute
    Return
    $Exists (bool)
    true if semantic structure attribute exists

    getChildElements

    return a list with the names of all child elements in the semantic structure of a given elementname.

    Syntax
    $aChildElements = $XMLStruct->getChildElements($ParentElement);
    Input
    $ParentElement (string)
    name of element in semantic structure
    Return
    $aChildElements (ref.array.string)
    reference to array that contains the names of all child elements
    of a given element name in the semantic structure

    getClass

    return class element exists

    Syntax
    my $Class = $XMLStruct->getClass($ElementName);
    Input
    $ElementName (string)
    name of element in semantic structure
    Return
    $Class (string)
    class of given element

    getDirectChildElements

    return all child elements of given element, that are direct children

    Syntax
    $aDirectChildElements = $XMLStruct->getDirectChildElements($ParentElement);
    Input
    $ParentElement (string)
    name of element in semantic structure
    Return
    $aDirectChildElements (ref.array)
    array with direct child elements sorted by Position

    getElements

    return a list with the names of all elements in the semantic structure. the names are always the pathes of the elements.

    Syntax
    $aElements = $XMLStruct->getElements();
    Example
    my @Elements = @{$XMLStruct->getElements()};
    Return
    $aElements (ref.array)
    reference to array that contains the names of all elements
    in the semantic structure

    getElementsWithoutParent

    return all elements of structure, that have no parent element in structure.

    Syntax
    my $aOrphanElements = $XMLStruct->getElementsWithoutParent($ElementName);
    Return
    $aOrphanElements (ref.array)
    reference to array contains all orphan elements

    getID

    return the identifier of given element

    Syntax
    my $hID = $XMLStruct->getID($ElementName);
    Input
    $ElementName (string)
    name of element in semantic structure
    Return
    $hID (ref.hash.string)
    hash contains key value pairs of ID

    getIDValue

    return part of id for element exists

    Syntax
    my $IDAttributeValue = $XMLStruct->getIDValue($ElementName,$IDAttributeName);
    Input
    $ElementName (string)
    name of element in semantic structure
    $IDAttributeName (string)
    name of id part
    Return
    $IDAttributeValue (string)
    value of id part for given element

    getRootElements

    return all root elements of semantic structure, elements with no parent

    Syntax
    my $aRootElements = $XMLStruct->getRootElements();
    Return
    $aRootElements (ref.array)
    array with root elements sorted by Position

    getTagAttribute

    return the value of tag attribute of the element

    Syntax
    my $TagAttributeValue = $XMLStruct->getTagAttribute($ElementName, $TagAttributeName);
    Input
    $ElementName (string)
    name of element in semantic structure
    $TagAttributeName (string)
    name of tag attribute in semantic structure
    Return
    $TagAttributeValue (string)
    value of tag attribute in elment

    getTagAttributes

    return a sorted array with names of tag attributes for given array.

    Syntax
    my $aAttributes = $XMLStruct->getTagAttributes($ElementName);
    Input
    $ElementName (string)
    name of element in semantic structure
    Return
    $aTagAttributes (ref.array)
    names of tag attributes of given element

    getTagAttributesHash

    return a sorted array with names of tag attributes for given array.

    Syntax
    my $hAttributes = $XMLStruct->getTagAttributesHash($ElementName);
    Input
    $ElementName (string)
    name of element in semantic structure
    Return
    $hTagAttributes (ref.hash)
    key value pairs of tag attributes of given element

    getXMLStructAttribute

    get the semantic structure attribute of element like _XMLStruct-Class=?

    Syntax
    my $XMLStructAttributeValue = $XMLStruct->getXMLStructAttribute($ElementName, $XMLStructAttributeName);
    Input
    $ElementName (string)
    name of element in semantic structure
    $XMLStructAttributeName (string)
    name of attribute in semantic structure
    Return
    $XMLStructAttributeValue (ref.hash/string/int)
    value of tag attribute in elment

    getXMLStructAttributes

    return a sorted array with names of semantic structure attributes for given array.

    Syntax
    my $aXMLStructAttributes = $XMLStruct->getXMLStructAttributes($ElementName);
    Input
    $ElementName (string)
    name of element in semantic structure
    Return
    $aXMLStructAttributes (ref.array)
    names of semantic structure attributes of given element

    getXMLStructAttributesHash

    get list of semantic structure attributes for element

    Syntax
    my $hXMLStructAttributes  = $XMLStruct->getXMLStructAttributesHash($ElementName);
    Input
    $ElementName (string)
    name of element in semantic structure
    Return
    $hXMLStructAttributes (ref.hash)
    list of names from semantic structure attributes

    getXMLType

    returns the type of xml [epages_standard|epages_translation]

    Syntax
    my $XMLType = $self->getXMLType();
    Return
    $XMLType (string)
    name of xml type

    getXMLTypeAddictedID

    return the identifier of given element addicted by the xml type the only known difference is AttributeValue tags in translation file, they are addressed only by Name because translation xml files have a global language tag.

    Syntax
    my $hID = $XMLStruct->getXMLTypeAddictedID($ElementName);
    Input
    $ElementName (string)
    name of element in semantic structure
    Return
    $hID (ref.hash.string)
    hash contains key value pairs of ID

    isEmpty

    return true if no elements are in semantic structure ore only elements that have no effect for sub pathes like global tags like <epages>, ...

    Syntax
    my $IsEmpty = $XMLStruct->isEmpty();
    Return
    $IsEmpty (bool)
    true if there are only elements are in structure that have no meaning

    isRootElement

    return true if given element is an root element, so it is an element with no parent.

    Syntax
    my $IsRootElements = $XMLStruct->isRootElement($Element);
    Input
    $ElementName (string)
    name of element in semantic structure
    Return
    $IsRootElement (boolean)
    true if element is an root element

    new

    constructor for semantic structure object.

    Syntax
    $self->new($XMLType);
    Input
    $XMLType (str)
    type of xml file, normally 'epages_standard' or 'epages_translation'

    parentElement

    returns the name of the parent of given element, dont check if exists in structure.

    Syntax
    my $ParentElementName = $XMLStruct->parentElement($ElementName);
    Input
    $ElementName (string)
    name of element in semantic structure
    Return
    $ParentElementName (string)
    only the name of the parent of given element

    setID

    set the identifier of given element, remember Element name have to be consistent to his id

    Syntax
    $XMLStruct->setID($ElementName, $hID);
    Example
     $XMLStruct->setID('/Test1/Test2/Example{ID1->Value1;ID2->Value2}', {'ID1' => 'Value1', 'ID2' => 'Value2'});
    Input
    $ElementName (string)
    name of element in semantic structure
    Return
    $hID (ref.hash.string)
    hash contains key value pairs of ID

    setTagAttribute

    set the attribute value of element in semantic structure

    Syntax
    $XMLStruct->setTagAttribute($ElementName, $TagAttributeName, $Value);
    Input
    $ElementName (string)
    name of element in semantic structure
    $TagAttributeName (string)
    name of tag attribute in semantic structure
    $Value (string)
    value to set

    setTagAttributes

    set the tag attributes for a semantic structure element. if a tag attribute already exists it will be overwrite.

    Syntax
    $XMLStruct->setTagAttributes($ElementName, $hTagAttributes);
    Input
    $ElementName (string)
    name of element in semantic structure
    $hTagAttributes (ref.hash)
    key value pairs of tag attributes

    setXMLStructAttribute

    set the semantic structure attribute of element like _XMLStruct-Class='Object'

    Syntax
    $XMLStruct->setXMLStructAttribute($ElementName, $XMLStructAttributeName, $XMLStructAttributeValue);
    Input
    $ElementName (string)
    name of element in semantic structure
    $XMLStructAttributeName (string)
    name of attribute in semantic structure
    $XMLStructAttributeValue (string)
    value of tag attribute in elment

    setXMLStructAttributes

    set the semantic structure attributes for an element

    Syntax
    $XMLStruct->setXMLStructAttributes($ElementName, $hXMLStructAttributes);
    Input
    $ElementName (string)
    name of element in semantic structure
    $hXMLStructAttributes (ref.hash.string)
    key value pairs of semantic structure attributes