Skip to content

Commit

Permalink
Use constant for root scope ID
Browse files Browse the repository at this point in the history
Signed-off-by: Jarno Elovirta <jarno@elovirta.com>
  • Loading branch information
jelovirt committed Oct 24, 2020
1 parent f46592b commit c38b3d8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/main/java/org/dita/dost/reader/KeyrefReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import static net.sf.saxon.s9api.streams.Steps.*;
import static net.sf.saxon.type.BuiltInAtomicType.STRING;
import static org.dita.dost.util.Constants.*;
import static org.dita.dost.util.KeyScope.ROOT_ID;
import static org.dita.dost.util.URLUtils.toURI;
import static org.dita.dost.util.XMLUtils.rootElement;

Expand Down Expand Up @@ -142,7 +143,7 @@ private KeyScope readScopes(final XdmNode doc) {
if (scopes.size() == 1 && scopes.get(0).name == null) {
return scopes.get(0);
} else {
return new KeyScope("#root", null, Collections.emptyMap(), scopes);
return new KeyScope(ROOT_ID, null, Collections.emptyMap(), scopes);
}
}

Expand All @@ -153,7 +154,7 @@ private List<KeyScope> readScopesRoot(final XdmNode root) {
readChildScopes(root, childScopes);
final String keyscope = root.attribute(ATTRIBUTE_NAME_KEYSCOPE);
if (keyscope == null || keyscope.trim().isEmpty()) {
return Collections.singletonList(new KeyScope("#root", null, keyDefs, childScopes));
return Collections.singletonList(new KeyScope(ROOT_ID, null, keyDefs, childScopes));
} else {
final List<KeyScope> res = new ArrayList<>();
for (final String scope : keyscope.split("\\s+")) {
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/dita/dost/util/KeyScope.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
*/
public class KeyScope {

public static final KeyScope EMPTY = new KeyScope(null, null, Collections.emptyMap(), Collections.emptyList());
public static final String ROOT_ID = "#root";
public static final KeyScope EMPTY = new KeyScope(ROOT_ID, null, Collections.emptyMap(), Collections.emptyList());

public final String id;
public final String name;
Expand Down

0 comments on commit c38b3d8

Please sign in to comment.