fix rendering for conditional references

This commit is contained in:
Grahame Grieve 2023-02-21 16:46:02 +11:00
parent 76a3129b30
commit 3eda8580fc
3 changed files with 35 additions and 10 deletions

View File

@ -43,6 +43,8 @@ public class ContextUtilities implements ProfileKnowledgeProvider {
private XVerExtensionManager xverManager;
private Map<String, String> oidCache = new HashMap<>();
private List<StructureDefinition> allStructuresList = new ArrayList<StructureDefinition>();
private List<String> canonicalResourceNames;
private List<String> concreteResourceNames;
public ContextUtilities(IWorkerContext context) {
super();
@ -197,13 +199,17 @@ public class ContextUtilities implements ProfileKnowledgeProvider {
* @return a list of the resource names that are canonical resources defined for this version
*/
public List<String> getCanonicalResourceNames() {
List<String> names = new ArrayList<>();
if (canonicalResourceNames == null) {
canonicalResourceNames = new ArrayList<>();
Set<String> names = new HashSet<>();
for (StructureDefinition sd : allStructures()) {
if (sd.getKind() == StructureDefinitionKind.RESOURCE && !sd.getAbstract() && hasUrlProperty(sd)) {
names.add(sd.getType());
}
}
return names;
canonicalResourceNames.addAll(Utilities.sorted(names));
}
return canonicalResourceNames;
}
/**
@ -370,5 +376,19 @@ public class ContextUtilities implements ProfileKnowledgeProvider {
return null;
}
public List<String> getConcreteResources() {
if (concreteResourceNames == null) {
concreteResourceNames = new ArrayList<>();
Set<String> names = new HashSet<>();
for (StructureDefinition sd : allStructures()) {
if (sd.getKind() == StructureDefinitionKind.RESOURCE && !sd.getAbstract()) {
names.add(sd.getType());
}
}
concreteResourceNames.addAll(Utilities.sorted(names));
}
return concreteResourceNames;
}
}

View File

@ -223,12 +223,15 @@ public abstract class ResourceRenderer extends DataRenderer {
tr = resolveReference(rw, r.getReference());
if (!r.getReference().startsWith("#")) {
if (tr != null && tr.getReference() != null)
if (tr != null && tr.getReference() != null) {
c = x.ah(tr.getReference());
else
c = x.ah(r.getReference());
} else if (r.getReference().contains("?")) {
x.tx("Conditional Reference: ");
c = x.code("");
} else {
c = x.ah(r.getReference());
}
} else {
c = x.ah(r.getReference());
}
} else {

View File

@ -150,7 +150,9 @@ public abstract class XhtmlFluent {
public XhtmlNode code(String text) {
return addTag("code").tx(text);
XhtmlNode code = addTag("code");
code.tx(text);
return code;
}
public XhtmlNode code() {