Skip to content

Commit

Permalink
PDF/UA-2. Fix getRoleMapToSameNamespaceTag
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximPlusov committed Jan 31, 2024
1 parent 6be93cd commit 4aa2449
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/main/java/org/verapdf/tools/TaggedPDFHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public static StructureType getDefaultStructureType(StructureType type) {
visitedWithNS.clear();
visitedWithoutNS.clear();
addVisited(type);
StructureType curr = getEquivalent(type);
StructureType curr = getEquivalent(type, StaticResources.getRoleMapHelper().getRoleMap());
if (curr == null || isVisited(curr)) {
return isStandardType(type) ? type : null;
}
Expand All @@ -170,7 +170,7 @@ public static StructureType getDefaultStructureType(StructureType type) {
return curr;
}
addVisited(curr);
curr = getEquivalent(curr);
curr = getEquivalent(curr, StaticResources.getRoleMapHelper().getRoleMap());
}
return null;
}
Expand All @@ -183,7 +183,7 @@ public static String getRoleMapToSameNamespaceTag(StructureType type) {
visitedWithoutNS.clear();
addVisited(type);
StructureType prev = type;
StructureType curr = getEquivalent(prev);
StructureType curr = getEquivalent(prev, Collections.emptyMap());
while (curr != null) {
if (curr.getNameSpaceURI() != null && curr.getNameSpaceURI().equals(prev.getNameSpaceURI())) {
return curr.getNameSpaceURI();
Expand All @@ -193,12 +193,12 @@ public static String getRoleMapToSameNamespaceTag(StructureType type) {
}
addVisited(curr);
prev = curr;
curr = getEquivalent(prev);
curr = getEquivalent(prev, Collections.emptyMap());
}
return null;
}

private static StructureType getEquivalent(StructureType type) {
private static StructureType getEquivalent(StructureType type, Map<ASAtom, ASAtom> roleMap) {
PDStructureNameSpace nameSpace = type.getNameSpace();
if (nameSpace != null) {
PDNameSpaceRoleMapping nameSpaceMapping = nameSpace.getNameSpaceMapping();
Expand All @@ -208,7 +208,7 @@ private static StructureType getEquivalent(StructureType type) {
return null;
}
}
ASAtom equiv = StaticResources.getRoleMapHelper().getRoleMap().get(type.getType());
ASAtom equiv = roleMap.get(type.getType());
return equiv == null ? null : StructureType.createStructureType(equiv);
}

Expand Down

0 comments on commit 4aa2449

Please sign in to comment.