Merge pull request #994 from hapifhir/gg-202211-xhtml-entities
Gg 202211 xhtml entities
This commit is contained in:
commit
b4d21b8263
|
@ -1,7 +1,7 @@
|
|||
## Validator Changes
|
||||
|
||||
* no changes
|
||||
* Validate HTML entities in XHTML in resources
|
||||
|
||||
## Other code changes
|
||||
|
||||
* no changes
|
||||
* Stop producing XHTML entities in resources when rendering
|
||||
|
|
|
@ -55,6 +55,7 @@ import org.hl7.fhir.dstu2016may.utils.JsonTrackingParser;
|
|||
import org.hl7.fhir.dstu2016may.utils.JsonTrackingParser.LocationData;
|
||||
import org.hl7.fhir.exceptions.DefinitionException;
|
||||
import org.hl7.fhir.exceptions.FHIRFormatError;
|
||||
import org.hl7.fhir.utilities.StringPair;
|
||||
import org.hl7.fhir.utilities.TextFile;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
|
||||
|
@ -249,7 +250,13 @@ public class JsonParser extends ParserBase {
|
|||
n.setValue(p.getAsString());
|
||||
if (!n.getProperty().isChoice() && n.getType().equals("xhtml")) {
|
||||
try {
|
||||
n.setXhtml(new XhtmlParser().setValidatorMode(policy == ValidationPolicy.EVERYTHING).parse(n.getValue(), null).getDocumentElement());
|
||||
XhtmlParser xp = new XhtmlParser();
|
||||
n.setXhtml(xp.parse(n.getValue(), null).getDocumentElement());
|
||||
if (policy == ValidationPolicy.EVERYTHING) {
|
||||
for (StringPair s : xp.getValidationIssues()) {
|
||||
logError(line(main), col(main), npath, IssueType.INVALID, s.getName() + s.getValue(), IssueSeverity.ERROR);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logError(line(main), col(main), npath, IssueType.INVALID, "Error parsing XHTML: "+e.getMessage(), IssueSeverity.ERROR);
|
||||
}
|
||||
|
|
|
@ -58,6 +58,7 @@ import org.hl7.fhir.dstu2016may.utils.XmlLocationAnnotator;
|
|||
import org.hl7.fhir.dstu2016may.utils.XmlLocationData;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.exceptions.FHIRFormatError;
|
||||
import org.hl7.fhir.utilities.StringPair;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueType;
|
||||
|
@ -265,7 +266,13 @@ public class XmlParser extends ParserBase {
|
|||
Property property = getElementProp(properties, child.getLocalName());
|
||||
if (property != null) {
|
||||
if (!property.isChoice() && "xhtml".equals(property.getType())) {
|
||||
XhtmlNode xhtml = new XhtmlParser().setValidatorMode(true).parseHtmlNode((org.w3c.dom.Element) child);
|
||||
XhtmlParser xp = new XhtmlParser();
|
||||
XhtmlNode xhtml = xp.parseHtmlNode((org.w3c.dom.Element) child);
|
||||
if (policy == ValidationPolicy.EVERYTHING) {
|
||||
for (StringPair s : xp.getValidationIssues()) {
|
||||
logError(line(child), col(child), path, IssueType.INVALID, s.getName() + " "+s.getValue(), IssueSeverity.ERROR);
|
||||
}
|
||||
}
|
||||
context.getChildren().add(new Element("div", property, "xhtml", new XhtmlComposer(true, false).compose(xhtml)).setXhtml(xhtml).markLocation(line(child), col(child)));
|
||||
} else {
|
||||
String npath = path+"/"+pathPrefix(child.getNamespaceURI())+child.getLocalName();
|
||||
|
|
|
@ -54,6 +54,7 @@ import org.hl7.fhir.dstu3.model.StructureDefinition;
|
|||
import org.hl7.fhir.exceptions.DefinitionException;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.exceptions.FHIRFormatError;
|
||||
import org.hl7.fhir.utilities.StringPair;
|
||||
import org.hl7.fhir.utilities.TextFile;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.json.JsonTrackingParser;
|
||||
|
@ -266,7 +267,13 @@ public class JsonParser extends ParserBase {
|
|||
n.setValue(p.getAsString());
|
||||
if (!n.getProperty().isChoice() && n.getType().equals("xhtml")) {
|
||||
try {
|
||||
n.setXhtml(new XhtmlParser().setValidatorMode(policy == ValidationPolicy.EVERYTHING).parse(n.getValue(), null).getDocumentElement());
|
||||
XhtmlParser xp = new XhtmlParser();
|
||||
n.setXhtml(xp.parse(n.getValue(), null).getDocumentElement());
|
||||
if (policy == ValidationPolicy.EVERYTHING) {
|
||||
for (StringPair s : xp.getValidationIssues()) {
|
||||
logError(line(main), col(main), npath, IssueType.INVALID, s.getName()+ " "+ s.getValue(), IssueSeverity.ERROR);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logError(line(main), col(main), npath, IssueType.INVALID, "Error parsing XHTML: "+e.getMessage(), IssueSeverity.ERROR);
|
||||
}
|
||||
|
|
|
@ -62,6 +62,7 @@ import org.hl7.fhir.dstu3.utils.formats.XmlLocationData;
|
|||
import org.hl7.fhir.exceptions.DefinitionException;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.exceptions.FHIRFormatError;
|
||||
import org.hl7.fhir.utilities.StringPair;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueType;
|
||||
|
@ -283,7 +284,13 @@ public class XmlParser extends ParserBase {
|
|||
Property property = getElementProp(properties, child.getLocalName());
|
||||
if (property != null) {
|
||||
if (!property.isChoice() && "xhtml".equals(property.getType())) {
|
||||
XhtmlNode xhtml = new XhtmlParser().setValidatorMode(true).parseHtmlNode((org.w3c.dom.Element) child);
|
||||
XhtmlParser xp = new XhtmlParser();
|
||||
XhtmlNode xhtml = xp.parseHtmlNode((org.w3c.dom.Element) child);
|
||||
if (policy == ValidationPolicy.EVERYTHING) {
|
||||
for (StringPair s : xp.getValidationIssues()) {
|
||||
logError(line(child), col(child), path, IssueType.INVALID, s.getName() + " "+s.getValue(), IssueSeverity.ERROR);
|
||||
}
|
||||
}
|
||||
context.getChildren().add(new Element("div", property, "xhtml", new XhtmlComposer(XhtmlComposer.XML).compose(xhtml)).setXhtml(xhtml).markLocation(line(child), col(child)));
|
||||
} else {
|
||||
String npath = path+"/"+pathPrefix(child.getNamespaceURI())+child.getLocalName();
|
||||
|
|
|
@ -55,6 +55,7 @@ import org.hl7.fhir.r4.formats.JsonCreatorCanonical;
|
|||
import org.hl7.fhir.r4.formats.JsonCreatorGson;
|
||||
import org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent;
|
||||
import org.hl7.fhir.r4.model.StructureDefinition;
|
||||
import org.hl7.fhir.utilities.StringPair;
|
||||
import org.hl7.fhir.utilities.TextFile;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.json.JsonTrackingParser;
|
||||
|
@ -286,7 +287,13 @@ public class JsonParser extends ParserBase {
|
|||
n.setValue(p.getAsString());
|
||||
if (!n.getProperty().isChoice() && n.getType().equals("xhtml")) {
|
||||
try {
|
||||
n.setXhtml(new XhtmlParser().setValidatorMode(policy == ValidationPolicy.EVERYTHING).parse(n.getValue(), null).getDocumentElement());
|
||||
XhtmlParser xp = new XhtmlParser();
|
||||
n.setXhtml(xp.parse(n.getValue(), null).getDocumentElement());
|
||||
if (policy == ValidationPolicy.EVERYTHING) {
|
||||
for (StringPair s : xp.getValidationIssues()) {
|
||||
logError(line(main), col(main), npath, IssueType.INVALID, s.getName() + " "+s.getValue(), IssueSeverity.ERROR);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logError(line(main), col(main), npath, IssueType.INVALID, "Error parsing XHTML: "+e.getMessage(), IssueSeverity.ERROR);
|
||||
}
|
||||
|
|
|
@ -63,6 +63,7 @@ import org.hl7.fhir.r4.utils.ToolingExtensions;
|
|||
import org.hl7.fhir.r4.utils.formats.XmlLocationAnnotator;
|
||||
import org.hl7.fhir.r4.utils.formats.XmlLocationData;
|
||||
import org.hl7.fhir.utilities.ElementDecoration;
|
||||
import org.hl7.fhir.utilities.StringPair;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueType;
|
||||
|
@ -296,8 +297,15 @@ public class XmlParser extends ParserBase {
|
|||
XhtmlNode xhtml;
|
||||
if (property.getDefinition().hasRepresentation(PropertyRepresentation.CDATEXT))
|
||||
xhtml = new CDANarrativeFormat().convert((org.w3c.dom.Element) child);
|
||||
else
|
||||
xhtml = new XhtmlParser().setValidatorMode(true).parseHtmlNode((org.w3c.dom.Element) child);
|
||||
else {
|
||||
XhtmlParser xp = new XhtmlParser();
|
||||
xhtml = xp.parseHtmlNode((org.w3c.dom.Element) child);
|
||||
if (policy == ValidationPolicy.EVERYTHING) {
|
||||
for (StringPair s : xp.getValidationIssues()) {
|
||||
logError(line(child), col(child), path, IssueType.INVALID, s.getName() + " "+s.getValue(), IssueSeverity.ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
context.getChildren().add(new Element(property.getName(), property, "xhtml", new XhtmlComposer(XhtmlComposer.XML, false).compose(xhtml)).setXhtml(xhtml).markLocation(line(child), col(child)));
|
||||
} else {
|
||||
String npath = path+"/"+pathPrefix(child.getNamespaceURI())+child.getLocalName();
|
||||
|
|
|
@ -56,6 +56,7 @@ import org.hl7.fhir.r4b.formats.JsonCreatorGson;
|
|||
import org.hl7.fhir.r4b.model.ElementDefinition.TypeRefComponent;
|
||||
import org.hl7.fhir.r4b.utils.FHIRPathEngine;
|
||||
import org.hl7.fhir.r4b.model.StructureDefinition;
|
||||
import org.hl7.fhir.utilities.StringPair;
|
||||
import org.hl7.fhir.utilities.TextFile;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.i18n.I18nConstants;
|
||||
|
@ -347,7 +348,13 @@ public class JsonParser extends ParserBase {
|
|||
}
|
||||
if (!n.getProperty().isChoice() && n.getType().equals("xhtml")) {
|
||||
try {
|
||||
n.setXhtml(new XhtmlParser().setValidatorMode(policy == ValidationPolicy.EVERYTHING).parse(n.getValue(), null).getDocumentElement());
|
||||
XhtmlParser xp = new XhtmlParser();
|
||||
n.setXhtml(xp.parse(n.getValue(), null).getDocumentElement());
|
||||
if (policy == ValidationPolicy.EVERYTHING) {
|
||||
for (StringPair s : xp.getValidationIssues()) {
|
||||
logError(line(main), col(main), npath, IssueType.INVALID, context.formatMessage(s.getName(), s.getValue()), IssueSeverity.ERROR);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logError(line(main), col(main), npath, IssueType.INVALID, context.formatMessage(I18nConstants.ERROR_PARSING_XHTML_, e.getMessage()), IssueSeverity.ERROR);
|
||||
}
|
||||
|
|
|
@ -64,6 +64,7 @@ import org.hl7.fhir.r4b.utils.ToolingExtensions;
|
|||
import org.hl7.fhir.r4b.utils.formats.XmlLocationAnnotator;
|
||||
import org.hl7.fhir.r4b.utils.formats.XmlLocationData;
|
||||
import org.hl7.fhir.utilities.ElementDecoration;
|
||||
import org.hl7.fhir.utilities.StringPair;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.i18n.I18nConstants;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
|
||||
|
@ -374,8 +375,15 @@ public class XmlParser extends ParserBase {
|
|||
XhtmlNode xhtml;
|
||||
if (property.getDefinition().hasRepresentation(PropertyRepresentation.CDATEXT))
|
||||
xhtml = new CDANarrativeFormat().convert((org.w3c.dom.Element) child);
|
||||
else
|
||||
xhtml = new XhtmlParser().setValidatorMode(true).parseHtmlNode((org.w3c.dom.Element) child);
|
||||
else {
|
||||
XhtmlParser xp = new XhtmlParser();
|
||||
xhtml = xp.parseHtmlNode((org.w3c.dom.Element) child);
|
||||
if (policy == ValidationPolicy.EVERYTHING) {
|
||||
for (StringPair s : xp.getValidationIssues()) {
|
||||
logError(line(child), col(child), path, IssueType.INVALID, context.formatMessage(s.getName(), s.getValue()), IssueSeverity.ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
Element n = new Element(property.getName(), property, "xhtml", new XhtmlComposer(XhtmlComposer.XML, false).compose(xhtml)).setXhtml(xhtml).markLocation(line(child), col(child));
|
||||
n.setPath(element.getPath()+"."+property.getName());
|
||||
element.getChildren().add(n);
|
||||
|
|
|
@ -537,7 +537,13 @@ public class JsonParser extends ParserBase {
|
|||
}
|
||||
if (!n.getProperty().isChoice() && n.getType().equals("xhtml")) {
|
||||
try {
|
||||
n.setXhtml(new XhtmlParser().setValidatorMode(policy == ValidationPolicy.EVERYTHING).parse(n.getValue(), null).getDocumentElement());
|
||||
XhtmlParser xhtml = new XhtmlParser();
|
||||
n.setXhtml(xhtml.setXmlMode(true).parse(n.getValue(), null).getDocumentElement());
|
||||
if (policy == ValidationPolicy.EVERYTHING) {
|
||||
for (StringPair s : xhtml.getValidationIssues()) {
|
||||
logError(line(main), col(main), npath, IssueType.INVALID, context.formatMessage(s.getName(), s.getValue()), IssueSeverity.ERROR);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logError(line(main), col(main), npath, IssueType.INVALID, context.formatMessage(I18nConstants.ERROR_PARSING_XHTML_, e.getMessage()), IssueSeverity.ERROR);
|
||||
}
|
||||
|
@ -545,8 +551,9 @@ public class JsonParser extends ParserBase {
|
|||
if (policy == ValidationPolicy.EVERYTHING) {
|
||||
// now we cross-check the primitive format against the stated type
|
||||
if (Utilities.existsInList(n.getType(), "boolean")) {
|
||||
if (!p.isBoolean())
|
||||
if (!p.isBoolean()) {
|
||||
logError(line(main), col(main), npath, IssueType.INVALID, context.formatMessage(I18nConstants.ERROR_PARSING_JSON_THE_PRIMITIVE_VALUE_MUST_BE_A_BOOLEAN), IssueSeverity.ERROR);
|
||||
}
|
||||
} else if (Utilities.existsInList(n.getType(), "integer", "unsignedInt", "positiveInt", "decimal")) {
|
||||
if (!p.isNumber())
|
||||
logError(line(main), col(main), npath, IssueType.INVALID, context.formatMessage(I18nConstants.ERROR_PARSING_JSON_THE_PRIMITIVE_VALUE_MUST_BE_A_NUMBER), IssueSeverity.ERROR);
|
||||
|
|
|
@ -53,6 +53,7 @@ import org.hl7.fhir.exceptions.FHIRFormatError;
|
|||
import org.hl7.fhir.r5.conformance.ProfileUtilities;
|
||||
import org.hl7.fhir.r5.context.IWorkerContext;
|
||||
import org.hl7.fhir.r5.elementmodel.Element.SpecialElement;
|
||||
import org.hl7.fhir.r5.elementmodel.ParserBase.ValidationPolicy;
|
||||
import org.hl7.fhir.r5.formats.FormatUtilities;
|
||||
import org.hl7.fhir.r5.formats.IParser.OutputStyle;
|
||||
import org.hl7.fhir.r5.model.DateTimeType;
|
||||
|
@ -63,6 +64,7 @@ import org.hl7.fhir.r5.utils.ToolingExtensions;
|
|||
import org.hl7.fhir.r5.utils.formats.XmlLocationAnnotator;
|
||||
import org.hl7.fhir.r5.utils.formats.XmlLocationData;
|
||||
import org.hl7.fhir.utilities.ElementDecoration;
|
||||
import org.hl7.fhir.utilities.StringPair;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.i18n.I18nConstants;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
|
||||
|
@ -389,8 +391,15 @@ public class XmlParser extends ParserBase {
|
|||
XhtmlNode xhtml;
|
||||
if (property.getDefinition().hasRepresentation(PropertyRepresentation.CDATEXT))
|
||||
xhtml = new CDANarrativeFormat().convert((org.w3c.dom.Element) child);
|
||||
else
|
||||
xhtml = new XhtmlParser().setValidatorMode(true).parseHtmlNode((org.w3c.dom.Element) child);
|
||||
else {
|
||||
XhtmlParser xp = new XhtmlParser();
|
||||
xhtml = xp.parseHtmlNode((org.w3c.dom.Element) child);
|
||||
if (policy == ValidationPolicy.EVERYTHING) {
|
||||
for (StringPair s : xp.getValidationIssues()) {
|
||||
logError(line(child, false), col(child, false), path, IssueType.INVALID, context.formatMessage(s.getName(), s.getValue()), IssueSeverity.ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
Element n = new Element(property.getName(), property, "xhtml", new XhtmlComposer(XhtmlComposer.XML, false).compose(xhtml)).setXhtml(xhtml).markLocation(line(child, false), col(child, false));
|
||||
n.setPath(element.getPath()+"."+property.getName());
|
||||
element.getChildren().add(n);
|
||||
|
|
|
@ -239,11 +239,9 @@ public class ElementWrappers {
|
|||
if (div == null) {
|
||||
div = new org.hl7.fhir.r5.elementmodel.Element("div", txt.getProperty().getChild(null, "div"));
|
||||
txt.getChildren().add(div);
|
||||
div.setValue(new XhtmlComposer(XhtmlComposer.XML, context.isPretty()).compose(x));
|
||||
}
|
||||
div.setValue(x.toString());
|
||||
div.setValue(new XhtmlComposer(XhtmlComposer.XML, context.isPretty()).compose(x));
|
||||
div.setXhtml(x);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -62,9 +62,9 @@ public class XVerExtensionManager {
|
|||
}
|
||||
}
|
||||
JsonObject root = lists.get(v);
|
||||
JsonObject path = root.getObj(e);
|
||||
JsonObject path = root.getObject(e);
|
||||
if (path == null) {
|
||||
path = root.getObj(e+"[x]");
|
||||
path = root.getObject(e+"[x]");
|
||||
}
|
||||
if (path == null) {
|
||||
return XVerExtensionStatus.Unknown;
|
||||
|
@ -85,9 +85,9 @@ public class XVerExtensionManager {
|
|||
String verTarget = VersionUtilities.getMajMin(context.getVersion());
|
||||
String e = url.substring(54);
|
||||
JsonObject root = lists.get(verSource);
|
||||
JsonObject path = root.getObj(e);
|
||||
JsonObject path = root.getObject(e);
|
||||
if (path == null) {
|
||||
path = root.getObj(e+"[x]");
|
||||
path = root.getObject(e+"[x]");
|
||||
}
|
||||
|
||||
StructureDefinition sd = new StructureDefinition();
|
||||
|
@ -115,8 +115,8 @@ public class XVerExtensionManager {
|
|||
ElementDefinition val = sd.getDifferential().addElement().setPath("Extension.value[x]").setMin(1);
|
||||
populateTypes(path, val, verSource, verTarget);
|
||||
} else if (path.has("elements")) {
|
||||
for (JsonElement i : path.getArr("elements").getItems()) {
|
||||
JsonObject elt = root.getObj(e+"."+i.toString());
|
||||
for (JsonElement i : path.forceArray("elements").getItems()) {
|
||||
JsonObject elt = root.getObject(e+"."+i.toString());
|
||||
if (elt != null) {
|
||||
String s = i.toString().replace("[x]", "");
|
||||
sd.getDifferential().addElement().setPath("Extension.extension").setSliceName(s);
|
||||
|
@ -134,7 +134,7 @@ public class XVerExtensionManager {
|
|||
} else {
|
||||
throw new FHIRException("Internal error - attempt to define extension for "+url+" when it is invalid");
|
||||
}
|
||||
if (path.has("modifier") && path.getBoolean("modifier")) {
|
||||
if (path.has("modifier") && path.asBoolean("modifier")) {
|
||||
ElementDefinition baseDef = new ElementDefinition("Extension");
|
||||
sd.getDifferential().getElement().add(0, baseDef);
|
||||
baseDef.setIsModifier(true);
|
||||
|
@ -143,7 +143,7 @@ public class XVerExtensionManager {
|
|||
}
|
||||
|
||||
public void populateTypes(JsonObject path, ElementDefinition val, String verSource, String verTarget) {
|
||||
for (JsonElement i : path.getArr("types").getItems()) {
|
||||
for (JsonElement i : path.forceArray("types").getItems()) {
|
||||
String s = i.toString();
|
||||
if (!s.startsWith("!")) {
|
||||
if (s.contains("(")) {
|
||||
|
|
|
@ -746,6 +746,8 @@ public class I18nConstants {
|
|||
public static final String SD_SPECIALIZED_TYPE_MATCHES = "SD_SPECIALIZED_TYPE_MATCHES";
|
||||
public static final String SD_CONSTRAINED_KIND_NO_MATCH = "SD_CONSTRAINED_KIND_NO_MATCH";
|
||||
public static final String SD_PATH_TYPE_MISMATCH = "SD_PATH_TYPE_MISMATCH";
|
||||
public static final String XHTML_XHTML_Image_Reference_Illegal = "XHTML_XHTML_Image_Reference_Illegal";
|
||||
public static final String XHTML_XHTML_Entity_Illegal = "XHTML_XHTML_Entity_Illegal";
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.json.JsonException;
|
||||
|
||||
|
||||
|
@ -61,6 +62,13 @@ public class JsonObject extends JsonElement {
|
|||
return propMap.containsKey(name);
|
||||
}
|
||||
|
||||
public void drop(String name) {
|
||||
if (propMap.containsKey(name)) {
|
||||
propMap.remove(name);
|
||||
properties.removeIf((JsonProperty item) -> name.equals(item.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
public List<JsonProperty> getProperties() {
|
||||
return properties;
|
||||
}
|
||||
|
@ -73,54 +81,110 @@ public class JsonObject extends JsonElement {
|
|||
}
|
||||
}
|
||||
|
||||
public JsonObject getObj(String name) {
|
||||
return (JsonObject) get(name);
|
||||
public boolean hasObject(String name) {
|
||||
return propMap.containsKey(name) && propMap.get(name).getValue().elementType() == JsonElementType.OBJECT;
|
||||
}
|
||||
|
||||
public JsonString getStr(String name) {
|
||||
return (JsonString) get(name);
|
||||
public boolean hasArray(String name) {
|
||||
return propMap.containsKey(name) && propMap.get(name).getValue().elementType() == JsonElementType.ARRAY;
|
||||
}
|
||||
|
||||
public JsonBoolean getBool(String name) {
|
||||
return (JsonBoolean) get(name);
|
||||
public boolean hasPrimitive(String name) {
|
||||
return propMap.containsKey(name) && propMap.get(name).getValue() instanceof JsonPrimitive;
|
||||
}
|
||||
|
||||
public JsonNumber getNum(String name) {
|
||||
return (JsonNumber) get(name);
|
||||
public boolean hasString(String name) {
|
||||
return propMap.containsKey(name) && propMap.get(name).getValue().elementType() == JsonElementType.STRING;
|
||||
}
|
||||
|
||||
public boolean hasNumber(String name) {
|
||||
return propMap.containsKey(name) && propMap.get(name).getValue().elementType() == JsonElementType.NUMBER;
|
||||
}
|
||||
|
||||
public boolean hasBoolean(String name) {
|
||||
return propMap.containsKey(name) && propMap.get(name).getValue().elementType() == JsonElementType.BOOLEAN;
|
||||
}
|
||||
|
||||
public boolean hasNull(String name) {
|
||||
return propMap.containsKey(name) && propMap.get(name).getValue().elementType() == JsonElementType.NULL;
|
||||
}
|
||||
|
||||
|
||||
public JsonObject getObject(String name) {
|
||||
return hasObject(name) ? (JsonObject) get(name) : null;
|
||||
}
|
||||
|
||||
public JsonString getString(String name) {
|
||||
return hasString(name) ? (JsonString) get(name) : null;
|
||||
}
|
||||
|
||||
public JsonBoolean getBoolean(String name) {
|
||||
return hasBoolean(name) ? (JsonBoolean) get(name) : null;
|
||||
}
|
||||
|
||||
public JsonNumber getNumber(String name) {
|
||||
return hasNumber(name) ? (JsonNumber) get(name) : null;
|
||||
}
|
||||
|
||||
public JsonNull getNull(String name) {
|
||||
return (JsonNull) get(name);
|
||||
return hasNull(name) ?(JsonNull) get(name) : null;
|
||||
}
|
||||
|
||||
public JsonArray getArr(String name) {
|
||||
return (JsonArray) get(name);
|
||||
public JsonArray getArray(String name) {
|
||||
return hasArray(name) ? (JsonArray) get(name) : null;
|
||||
}
|
||||
|
||||
public Integer getInteger(String name) {
|
||||
public Integer asInteger(String name) {
|
||||
if (hasNumber(name)) {
|
||||
return ((JsonNumber) get(name)).getInteger();
|
||||
}
|
||||
|
||||
public String getString(String name) {
|
||||
return ((JsonPrimitive) get(name)).toString();
|
||||
if (hasPrimitive(name)) {
|
||||
String s = asString(name);
|
||||
if (Utilities.isInteger(s)) {
|
||||
return Integer.parseInt(s);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Boolean getBoolean(String name) {
|
||||
return has(name) ? ((JsonBoolean) get(name)).isValue() : false;
|
||||
public String asString(String name) {
|
||||
return hasPrimitive(name) ? ((JsonPrimitive) get(name)).toString() : null;
|
||||
}
|
||||
|
||||
public JsonObject forceObj(String name) throws JsonException {
|
||||
public boolean asBoolean(String name) {
|
||||
if (hasBoolean(name)) {
|
||||
return ((JsonBoolean) get(name)).isValue();
|
||||
}
|
||||
if (hasPrimitive(name)) {
|
||||
String s = asString(name);
|
||||
if ("true".equals(s)) {
|
||||
return true;
|
||||
}
|
||||
if ("false".equals(s)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public JsonObject forceObject(String name) throws JsonException {
|
||||
if (has(name) && !hasObject(name)) {
|
||||
drop(name);
|
||||
}
|
||||
if (!has(name)) {
|
||||
add(name, new JsonObject());
|
||||
}
|
||||
return getObj(name);
|
||||
return getObject(name);
|
||||
}
|
||||
|
||||
public JsonArray forceArr(String name) throws JsonException {
|
||||
public JsonArray forceArray(String name) throws JsonException {
|
||||
if (has(name) && !hasArray(name)) {
|
||||
drop(name);
|
||||
}
|
||||
if (!has(name)) {
|
||||
add(name, new JsonArray());
|
||||
}
|
||||
return getArr(name);
|
||||
return getArray(name);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -930,6 +930,9 @@ public class NpmPackage {
|
|||
for (String s : folder.content.keySet()) {
|
||||
byte[] b = folder.content.get(s);
|
||||
String name = n+"/"+s;
|
||||
if (b == null) {
|
||||
System.out.println(name+" is null");
|
||||
} else {
|
||||
indexer.seeFile(s, b);
|
||||
if (!s.equals(".index.json") && !s.equals("package.json")) {
|
||||
TarArchiveEntry entry = new TarArchiveEntry(name);
|
||||
|
@ -939,6 +942,7 @@ public class NpmPackage {
|
|||
tar.closeArchiveEntry();
|
||||
}
|
||||
}
|
||||
}
|
||||
byte[] cnt = indexer.build().getBytes(StandardCharsets.UTF_8);
|
||||
TarArchiveEntry entry = new TarArchiveEntry(n+"/.index.json");
|
||||
entry.setSize(cnt.length);
|
||||
|
|
|
@ -28,7 +28,7 @@ public class PackageHacker {
|
|||
private static boolean useSecureReferences = false;
|
||||
|
||||
public static void main(String[] args) throws FileNotFoundException, IOException {
|
||||
new PackageHacker().edit("/Users/grahamegrieve/web/hl7.org/fhir/us/sdoh-clinicalcare/2022Jan/package.tgz");
|
||||
new PackageHacker().edit("/Users/grahamegrieve/work/www.fhir.org/source/guides/chile/hl7.fhir.cl.corecl#1.0.0.tgz");
|
||||
}
|
||||
|
||||
private void edit(String name) throws FileNotFoundException, IOException {
|
||||
|
@ -80,7 +80,8 @@ public class PackageHacker {
|
|||
private void change(JsonObject npm) throws FileNotFoundException, IOException {
|
||||
// fixVersions(npm);
|
||||
// npm.remove("notForPublication");
|
||||
// npm.addProperty("url", "http://hl7.org/fhir/us/carin-rtpbc/STU1");
|
||||
npm.remove("url");
|
||||
npm.addProperty("url", "https://hl7chile.cl/fhir/ig/CoreCL/1.7.0");
|
||||
// npm.remove("name");
|
||||
// npm.addProperty("name", "hl7.fhir.uv.smart-app-launch");
|
||||
// npm.remove("canonical");
|
||||
|
@ -102,7 +103,7 @@ public class PackageHacker {
|
|||
// dep.addProperty("hl7.fhir.r4.examples", "4.0.1");
|
||||
// dep.addProperty("hl7.fhir.r4.expansions", "4.0.1");
|
||||
// dep.addProperty("hl7.fhir.r4.elements", "4.0.1");
|
||||
npm.addProperty("jurisdiction", "urn:iso:std:iso:3166#US");
|
||||
// npm.addProperty("jurisdiction", "urn:iso:std:iso:3166#CL");
|
||||
}
|
||||
|
||||
private void fixVersionInContent(Map<String, byte[]> content) {
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -251,6 +251,8 @@ Validation_VAL_Unknown_Profile = Unknown profile {0}
|
|||
VALIDATION_VAL_PROFILE_DEPENDS_NOT_RESOLVED = Profile {1} identifies {2} as a dependency (using the extension http://hl7.org/fhir/StructureDefinition/structuredefinition-dependencies), but this profile could not be found
|
||||
XHTML_XHTML_Attribute_Illegal = Illegal attribute name in the XHTML (''{0}'' on ''{1}'')
|
||||
XHTML_XHTML_Element_Illegal = Illegal element name in the XHTML (''{0}'')
|
||||
XHTML_XHTML_Entity_Illegal = Illegal entity in the XHTML (''{0}'')
|
||||
XHTML_XHTML_Image_Reference_Illegal = Illegal Image Reference in the XHTML (''{0}'')
|
||||
XHTML_XHTML_NS_InValid = Wrong namespace on the XHTML (''{0}'', should be ''{1}'')
|
||||
XHTML_XHTML_Name_Invalid = Wrong name on the XHTML (''{0}'') - must start with div
|
||||
_DT_Fixed_Wrong = Value is ''{0}'' but must be ''{1}''
|
||||
|
|
|
@ -26,7 +26,7 @@ public class JsonParserTests {
|
|||
public void testComments2() throws IOException, JsonException {
|
||||
JsonObject obj = JsonParser.parseObject("{\n // some comment \n \"n1\" : \"v1\"\n}\n", true);
|
||||
Assertions.assertEquals(0, obj.getComments().size());
|
||||
JsonString c = obj.getStr("n1");
|
||||
JsonString c = obj.getString("n1");
|
||||
Assertions.assertEquals(1, c.getComments().size());
|
||||
Assertions.assertEquals("some comment", c.getComments().get(0));
|
||||
Assertions.assertEquals("{\"n1\":\"v1\"}", JsonParser.compose(obj, false));
|
||||
|
@ -38,7 +38,7 @@ public class JsonParserTests {
|
|||
JsonObject obj = JsonParser.parseObject("// some comment\n{\n \"n1\" : \"v1\"\n}\n", true);
|
||||
Assertions.assertEquals(1, obj.getComments().size());
|
||||
Assertions.assertEquals("some comment", obj.getComments().get(0));
|
||||
JsonString c = obj.getStr("n1");
|
||||
JsonString c = obj.getString("n1");
|
||||
Assertions.assertEquals(0, c.getComments().size());
|
||||
Assertions.assertEquals("{\"n1\":\"v1\"}", JsonParser.compose(obj, false));
|
||||
Assertions.assertEquals("// some comment\n{\n \"n1\" : \"v1\"\n}\n", JsonParser.compose(obj, true));
|
||||
|
@ -539,7 +539,7 @@ public class JsonParserTests {
|
|||
public void testDuplicates2() throws IOException, JsonException {
|
||||
JsonObject e = JsonParser.parseObject("{ \"n\" : 1, \"n\" : 2 }", false, true);
|
||||
Assertions.assertEquals(2, e.getProperties().size());
|
||||
Assertions.assertEquals(2, e.getInteger("n"));
|
||||
Assertions.assertEquals(2, e.asInteger("n"));
|
||||
Assertions.assertEquals("{\"n\":1,\"n\":2}", JsonParser.compose(e));
|
||||
}
|
||||
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -19,7 +19,7 @@
|
|||
|
||||
<properties>
|
||||
<hapi_fhir_version>5.4.0</hapi_fhir_version>
|
||||
<validator_test_case_version>1.1.123</validator_test_case_version>
|
||||
<validator_test_case_version>1.1.124</validator_test_case_version>
|
||||
<junit_jupiter_version>5.7.1</junit_jupiter_version>
|
||||
<junit_platform_launcher_version>1.8.2</junit_platform_launcher_version>
|
||||
<maven_surefire_version>3.0.0-M5</maven_surefire_version>
|
||||
|
|
Loading…
Reference in New Issue