rendering improvements for xver IG

This commit is contained in:
Grahame Grieve 2024-03-14 16:47:23 +11:00
parent 3c39cafbcb
commit 93c98b551a
2 changed files with 35 additions and 17 deletions

View File

@ -159,10 +159,15 @@ public class DataRenderer extends Renderer implements CodeResolver {
parts[0] = parts[0].substring(0, parts[0].indexOf(".")); parts[0] = parts[0].substring(0, parts[0].indexOf("."));
} }
StructureDefinition p = getContext().getWorker().fetchResource(StructureDefinition.class, parts[0]); StructureDefinition p = getContext().getWorker().fetchResource(StructureDefinition.class, parts[0]);
if (p == null) if (p == null) {
p = getContext().getWorker().fetchTypeDefinition(parts[0]); p = getContext().getWorker().fetchTypeDefinition(parts[0]);
if (p == null) }
if (context.getTypeMap().containsKey(parts[0])) {
p = getContext().getWorker().fetchTypeDefinition(context.getTypeMap().get(parts[0]));
}
if (p == null) {
p = getContext().getWorker().fetchResource(StructureDefinition.class, link); p = getContext().getWorker().fetchResource(StructureDefinition.class, link);
}
if (p != null) { if (p != null) {
if ("Extension".equals(p.getType())) { if ("Extension".equals(p.getType())) {
path = null; path = null;
@ -175,8 +180,9 @@ public class DataRenderer extends Renderer implements CodeResolver {
if (url == null) { if (url == null) {
url = p.getUserString("filename"); url = p.getUserString("filename");
} }
} else } else {
throw new DefinitionException("Unable to resolve markdown link "+link); throw new DefinitionException("Unable to resolve markdown link "+link);
}
text = left+"["+link+"]("+url+(path == null ? "" : "#"+path)+")"+right; text = left+"["+link+"]("+url+(path == null ? "" : "#"+path)+")"+right;
} }
@ -1201,6 +1207,11 @@ public class DataRenderer extends Renderer implements CodeResolver {
protected String displayIdentifier(Identifier ii) { protected String displayIdentifier(Identifier ii) {
String s = Utilities.noString(ii.getValue()) ? "?ngen-9?" : ii.getValue(); String s = Utilities.noString(ii.getValue()) ? "?ngen-9?" : ii.getValue();
if ("urn:ietf:rfc:3986".equals(ii.getSystem()) && s.startsWith("urn:oid:")) {
s = "OID:"+s.substring(8);
} else if ("urn:ietf:rfc:3986".equals(ii.getSystem()) && s.startsWith("urn:uuid:")) {
s = "UUID:"+s.substring(9);
} else {
NamingSystem ns = context.getContext().getNSUrlMap().get(ii.getSystem()); NamingSystem ns = context.getContext().getNSUrlMap().get(ii.getSystem());
if (ns != null) { if (ns != null) {
s = ns.present()+"#"+s; s = ns.present()+"#"+s;
@ -1215,6 +1226,7 @@ public class DataRenderer extends Renderer implements CodeResolver {
} else if (ii.hasSystem()) { } else if (ii.hasSystem()) {
s = ii.getSystem()+"#"+s; s = ii.getSystem()+"#"+s;
} }
}
if (ii.hasUse() || ii.hasPeriod()) { if (ii.hasUse() || ii.hasPeriod()) {
s = s + "\u00A0("; s = s + "\u00A0(";

View File

@ -216,6 +216,7 @@ public class RenderingContext {
private Map<KnownLinkType, String> links = new HashMap<>(); private Map<KnownLinkType, String> links = new HashMap<>();
private Map<String, String> namedLinks = new HashMap<>(); private Map<String, String> namedLinks = new HashMap<>();
private boolean addName = false; private boolean addName = false;
private Map<String, String> typeMap = new HashMap<>(); // type aliases that can be resolved in Markdown type links (mainly for cross-version usage)
/** /**
* *
@ -281,6 +282,7 @@ public class RenderingContext {
res.changeVersion = changeVersion; res.changeVersion = changeVersion;
res.terminologyServiceOptions = terminologyServiceOptions.copy(); res.terminologyServiceOptions = terminologyServiceOptions.copy();
res.typeMap.putAll(typeMap);
return res; return res;
} }
@ -739,5 +741,9 @@ public class RenderingContext {
return this; return this;
} }
public Map<String, String> getTypeMap() {
return typeMap;
}
} }