diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/JsonParser.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/JsonParser.java index 9ee5eca39..4fb4b1433 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/JsonParser.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/JsonParser.java @@ -486,6 +486,8 @@ public class JsonParser extends ParserBase { if (element.hasValue()) primitiveValue(name, element); name = "_"+name; + if (element.getType().equals("xhtml")) + json.anchor("end-xhtml"); } if (element.hasChildren()) { open(name, linkResolver == null ? null : linkResolver.resolveProperty(element.getProperty())); diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/XmlParser.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/XmlParser.java index a5e83d20c..4ebc2fcb4 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/XmlParser.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/XmlParser.java @@ -501,8 +501,10 @@ public class XmlParser extends ParserBase { String rawXhtml = element.getValue(); if (isCdaText(element.getProperty())) { new CDANarrativeFormat().convert(xml, element.getXhtml()); - } else + } else { xml.escapedText(rawXhtml); + xml.anchor("end-xhtml"); + } } else if (isText(element.getProperty())) { if (linkResolver != null) xml.link(linkResolver.resolveProperty(element.getProperty())); diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/formats/JsonCreator.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/formats/JsonCreator.java index 3f2f434ac..62b232152 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/formats/JsonCreator.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/formats/JsonCreator.java @@ -59,4 +59,5 @@ public interface JsonCreator { // only used by an creator that actually produces xhtml void link(String href); + void anchor(String string); } diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/formats/JsonCreatorCanonical.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/formats/JsonCreatorCanonical.java index f01b92d74..28d93f6ac 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/formats/JsonCreatorCanonical.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/formats/JsonCreatorCanonical.java @@ -262,5 +262,10 @@ public class JsonCreatorCanonical implements JsonCreator { // not used } + @Override + public void anchor(String name) { + // not used + } + } diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/formats/JsonCreatorDirect.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/formats/JsonCreatorDirect.java index 386bc47c3..67550b4a1 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/formats/JsonCreatorDirect.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/formats/JsonCreatorDirect.java @@ -189,4 +189,10 @@ public class JsonCreatorDirect implements JsonCreator { } + @Override + public void anchor(String name) { + // not used + } + + } diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/formats/JsonCreatorGson.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/formats/JsonCreatorGson.java index b0e179662..04c158401 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/formats/JsonCreatorGson.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/formats/JsonCreatorGson.java @@ -106,4 +106,9 @@ public class JsonCreatorGson implements JsonCreator { value(new BigDecimal(value)); } + @Override + public void anchor(String name) { + // not used + } + } diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/NPMPackageGenerator.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/NPMPackageGenerator.java index 6e242521c..2cbec5818 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/NPMPackageGenerator.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/NPMPackageGenerator.java @@ -283,7 +283,7 @@ public class NPMPackageGenerator { // also, for cache management on current builds, generate a little manifest Gson gson = new GsonBuilder().setPrettyPrinting().create(); String json = gson.toJson(packageManifest); - TextFile.stringToFile(json, Utilities.changeFileExt(destFile, ".manifest.json")); + TextFile.stringToFile(json, Utilities.changeFileExt(destFile, ".manifest.json"), false); } public String filename() { diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/StructureMapUtilities.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/StructureMapUtilities.java index 1d596785e..bf200e53a 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/StructureMapUtilities.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/StructureMapUtilities.java @@ -1363,13 +1363,29 @@ public class StructureMapUtilities { vars.add(VariableMode.INPUT, getInputName(g, StructureMapInputMode.SOURCE, "source"), source); if (target != null) vars.add(VariableMode.OUTPUT, getInputName(g, StructureMapInputMode.TARGET, "target"), target); + else if (getInputName(g, StructureMapInputMode.TARGET, null) != null) { + String type = getInputType(g, StructureMapInputMode.TARGET); + throw new Error("not handled yet: creating a type of "+type); + } executeGroup("", context, map, vars, g, true); if (target instanceof Element) ((Element) target).sort(); } - private String getInputName(StructureMapGroupComponent g, StructureMapInputMode mode, String def) throws DefinitionException { + private String getInputType(StructureMapGroupComponent g, StructureMapInputMode mode) { + String type = null; + for (StructureMapGroupInputComponent inp : g.getInput()) { + if (inp.getMode() == mode) + if (type != null) + throw new DefinitionException("This engine does not support multiple source inputs"); + else + type = inp.getType(); + } + return type; + } + + private String getInputName(StructureMapGroupComponent g, StructureMapInputMode mode, String def) throws DefinitionException { String name = null; for (StructureMapGroupInputComponent inp : g.getInput()) { if (inp.getMode() == mode) diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/TextFile.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/TextFile.java index 47ae8bb59..4a871ed93 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/TextFile.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/TextFile.java @@ -200,5 +200,12 @@ public class TextFile { return streamToString(new ByteArrayInputStream(bs)); } + public static String bytesToString(byte[] bs, boolean removeBOM) throws IOException { + if (removeBOM) + return streamToString(new ByteArrayInputStream(bs)).replace("\uFEFF", ""); + else + return streamToString(new ByteArrayInputStream(bs)); + } + } diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/xml/IXMLWriter.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/xml/IXMLWriter.java index cba372f1f..005a27536 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/xml/IXMLWriter.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/xml/IXMLWriter.java @@ -119,5 +119,5 @@ public interface IXMLWriter { // this is only implemented by an implementation that is producing an xhtml representation, and is able to render elements as hyperlinks public abstract void link(String href); - + public abstract void anchor(String name); } diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/xml/XMLWriter.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/xml/XMLWriter.java index 626b925fa..d6eb59daf 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/xml/XMLWriter.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/xml/XMLWriter.java @@ -902,6 +902,11 @@ public class XMLWriter extends OutputStreamWriter implements IXMLWriter { } + @Override + public void anchor(String name) { + // ignore this + } + @Override public void decorate(ElementDecoration element) throws IOException { // nothing...