Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | 424x 424x 11488x 11488x 6079x 424x 106x 106x 625x 340x 106x | import type { Document as XmlDocument, Element as XmlElement } from '@xmldom/xmldom';
export function buildIdMap(document: XmlDocument): Map<string, XmlElement> {
const elementsById = new Map<string, XmlElement>();
for (const element of Array.from(document.getElementsByTagName('*'))) {
const id = element.getAttribute('id');
if (id) {
elementsById.set(id, element);
}
}
return elementsById;
}
export function collectNamespaceDeclarations(element: XmlElement): Record<string, string> {
const namespaces: Record<string, string> = {};
for (const attribute of Array.from(element.attributes)) {
if (attribute.name.startsWith('xmlns:')) {
namespaces[attribute.name.slice(6)] = attribute.value;
}
}
return namespaces;
} |