Skip to content

[BUG]: Regression regarding Id attribute detection in addAllReferences, and Id attribute handling of KeyInfo/Objects #520

@shunkica

Description

@shunkica

When the source document already contains an Id attribute, but it is prefixed with a namespace, eg foo:Id, the ensureHasId function will detect this Id and move on because it only looks for the Id part in the localName. However in the addAllReferences funciton, the logic is to look for the Id attributes without prefixes only.

 for (const attr of this.idAttributes) {
    id = node.getAttribute(attr);
    if (id) {
        break;
    }
}

Therefore preexisting prefixed Id attributes are not detected and the error No ID attribute found on node for reference: ${ref.xpath} is thrown.

Aditionally, since Objects and KeyInfo are added after ensureHasId is ran, if they do not have Id attributes already defined in their configuration, they will not be automatically added.

The solution for both problems is to run ensureHasId() once again in the addAllReferences() function instead of trying to re-detect the Id attribute.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions