diff --git a/clixon/element.py b/clixon/element.py index 609ff1e..bdffc28 100644 --- a/clixon/element.py +++ b/clixon/element.py @@ -6,6 +6,7 @@ class Element(object): + _creatortag = None def __init__( self, name: Optional[str] = "root", @@ -466,6 +467,29 @@ def findall(self, name: str) -> list: return self.get_elements(name=name, recursive=True) + def set_creator(self,creator: str) -> None: + """ + Set the creator tag to all class instances + :creator string: Valid XPath creator tag + :return: None + :rtype: None + """ + Element._creatortag = creator + + def tag_creator(self) -> None: + """ + Apply creator tag to Element + :return: self + :rtype: Element + """ + if Element._creatortag: + attribs = self.get_attributes() + attribs['cl:creator'] = Element._creatortag + self.set_attributes(attribs) + return self + else: + raise("Creator tag not defined") + def __getitem__(self, key: str) -> Optional[dict]: """ Return the attributes of the element.