Dear Gitlab users, due to maintenance reasons, Gitlab will not be available on Thursday 30.09.2021 from 5:00 pm to approximately 5:30 pm.

Commit 2cdbecac authored by Andreas Wagner's avatar Andreas Wagner
Browse files

Fix DOI replacing.

parent 56cd53ef
......@@ -298,8 +298,23 @@ func MixinDOI(r io.Reader, doi string, c *tei2zenodo.Config) (string, error) {
return "", tei2zenodo.NewError("errParse", fmt.Sprintf("supposed to write new DOI but XML file had no element to be found at configured parent path %s", c.WriteDOI.ParentPath), 500, nil)
}
// Try to find the first child element of type ElementType
tElmnt := pElmnt.FindElement(c.WriteDOI.ElementType)
// Try to find the first child element of type ElementType having all necessary attributes
var targetPathString string
if c.WriteDOI.AttributeName != "" {
targetPathString = c.WriteDOI.ElementType + `[@` + c.WriteDOI.AttributeName + `]`
} else {
targetPathString = c.WriteDOI.ElementType
}
for i := 0; i < len(c.WriteDOI.OtherAttributes); i++ {
targetPathString += "[@" + c.WriteDOI.OtherAttributes[i].AttName + "='" + c.WriteDOI.OtherAttributes[i].Value + "']"
}
log.Debugf("Mixin DOI - search element at path %s", targetPathString)
tElmnt := pElmnt.FindElement(targetPathString)
if tElmnt != nil {
log.Debugf("Mixin DOI - found element at %s", tElmnt.GetPath())
} else {
log.Debugf("Mixin DOI - could not find element")
}
if tElmnt == nil || c.WriteDOI.Mode == "add" { // If mode = "add" or pElemnt/elementType cannot be found ...
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment