From 7d91d946e89ab23f90d4935dd8df0a5310ddca74 Mon Sep 17 00:00:00 2001 From: Maxim Date: Mon, 15 Jul 2024 19:28:15 +0300 Subject: [PATCH] Fix getRoleMapToSameNamespaceTag and isCircularMappingExist --- src/main/java/org/verapdf/tools/TaggedPDFHelper.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/verapdf/tools/TaggedPDFHelper.java b/src/main/java/org/verapdf/tools/TaggedPDFHelper.java index 171612a3..dee070c2 100644 --- a/src/main/java/org/verapdf/tools/TaggedPDFHelper.java +++ b/src/main/java/org/verapdf/tools/TaggedPDFHelper.java @@ -186,6 +186,9 @@ public static String getRoleMapToSameNamespaceTag(StructureType type) { StructureType curr = getEquivalent(prev, Collections.emptyMap()); Map processedTypes = new HashMap<>(); while (curr != null) { + if (prev.getNameSpaceURI() != null) { + processedTypes.put(prev.getNameSpaceURI(), prev.getType()); + } if (curr.getNameSpaceURI() != null && processedTypes.containsKey(curr.getNameSpaceURI())) { ASAtom processedType = processedTypes.get(curr.getNameSpaceURI()); if (curr.getType() != null && !Objects.equals(curr.getType(), processedType)) { @@ -196,9 +199,6 @@ public static String getRoleMapToSameNamespaceTag(StructureType type) { if (isVisited(curr)) { return null; } - if (curr.getNameSpaceURI() != null) { - processedTypes.put(curr.getNameSpaceURI(), curr.getType()); - } addVisited(curr); prev = curr; curr = getEquivalent(prev, Collections.emptyMap()); @@ -217,6 +217,9 @@ public static Boolean isCircularMappingExist(StructureType type) { StructureType curr = getEquivalent(prev, Collections.emptyMap()); Map processedTypes = new HashMap<>(); while (curr != null) { + if (prev.getNameSpaceURI() != null) { + processedTypes.put(prev.getNameSpaceURI(), prev.getType()); + } if (curr.getNameSpaceURI() != null && processedTypes.containsKey(curr.getNameSpaceURI())) { ASAtom processedType = processedTypes.get(curr.getNameSpaceURI()); if (curr.getType() != null && Objects.equals(curr.getType(), processedType)) { @@ -226,9 +229,6 @@ public static Boolean isCircularMappingExist(StructureType type) { if (isVisited(curr)) { return false; } - if (curr.getNameSpaceURI() != null) { - processedTypes.put(curr.getNameSpaceURI(), curr.getType()); - } addVisited(curr); prev = curr; curr = getEquivalent(prev, Collections.emptyMap());