Update empty xml_root_path sanity check case.

Also added tests for it.

Added comment to the *HierarchyPath.AsString() function,
addressing the issue of not being able to retrieve the
element when the root path is equal to the path that
is being processed.
This commit is contained in:
ionutboangiu
2023-10-13 10:38:37 -04:00
committed by Dan Christian Bogos
parent 950c5279a6
commit 0bc94857ca
3 changed files with 72 additions and 8 deletions

View File

@@ -650,6 +650,12 @@ func (hP HierarchyPath) AsString(sep string, prefix bool) string {
if prefix {
strHP.WriteString(sep)
}
// TODO: Since this function can convert both the full and the relative HierarchyPath to a string, with
// prefix telling us which is which (true -> full path, false -> relative path), we should consider
// returning the '.' character when prefix == false. Currently, because we are returning an empty string
// if the path we are currently parsing is equal to the root path, when we attempt to retrieve the element
// we receive the error "expr expression is nil".
if len(hP) == 0 {
return strHP.String()
}