embed anchors at end of narrative for JSON & XML
This commit is contained in:
parent
5fb54f8889
commit
024d6dc935
|
@ -486,6 +486,8 @@ public class JsonParser extends ParserBase {
|
||||||
if (element.hasValue())
|
if (element.hasValue())
|
||||||
primitiveValue(name, element);
|
primitiveValue(name, element);
|
||||||
name = "_"+name;
|
name = "_"+name;
|
||||||
|
if (element.getType().equals("xhtml"))
|
||||||
|
json.anchor("end-xhtml");
|
||||||
}
|
}
|
||||||
if (element.hasChildren()) {
|
if (element.hasChildren()) {
|
||||||
open(name, linkResolver == null ? null : linkResolver.resolveProperty(element.getProperty()));
|
open(name, linkResolver == null ? null : linkResolver.resolveProperty(element.getProperty()));
|
||||||
|
|
|
@ -501,8 +501,10 @@ public class XmlParser extends ParserBase {
|
||||||
String rawXhtml = element.getValue();
|
String rawXhtml = element.getValue();
|
||||||
if (isCdaText(element.getProperty())) {
|
if (isCdaText(element.getProperty())) {
|
||||||
new CDANarrativeFormat().convert(xml, element.getXhtml());
|
new CDANarrativeFormat().convert(xml, element.getXhtml());
|
||||||
} else
|
} else {
|
||||||
xml.escapedText(rawXhtml);
|
xml.escapedText(rawXhtml);
|
||||||
|
xml.anchor("end-xhtml");
|
||||||
|
}
|
||||||
} else if (isText(element.getProperty())) {
|
} else if (isText(element.getProperty())) {
|
||||||
if (linkResolver != null)
|
if (linkResolver != null)
|
||||||
xml.link(linkResolver.resolveProperty(element.getProperty()));
|
xml.link(linkResolver.resolveProperty(element.getProperty()));
|
||||||
|
|
|
@ -59,4 +59,5 @@ public interface JsonCreator {
|
||||||
|
|
||||||
// only used by an creator that actually produces xhtml
|
// only used by an creator that actually produces xhtml
|
||||||
void link(String href);
|
void link(String href);
|
||||||
|
void anchor(String string);
|
||||||
}
|
}
|
||||||
|
|
|
@ -262,5 +262,10 @@ public class JsonCreatorCanonical implements JsonCreator {
|
||||||
// not used
|
// not used
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void anchor(String name) {
|
||||||
|
// not used
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -189,4 +189,10 @@ public class JsonCreatorDirect implements JsonCreator {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void anchor(String name) {
|
||||||
|
// not used
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,4 +106,9 @@ public class JsonCreatorGson implements JsonCreator {
|
||||||
value(new BigDecimal(value));
|
value(new BigDecimal(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void anchor(String name) {
|
||||||
|
// not used
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -283,7 +283,7 @@ public class NPMPackageGenerator {
|
||||||
// also, for cache management on current builds, generate a little manifest
|
// also, for cache management on current builds, generate a little manifest
|
||||||
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||||
String json = gson.toJson(packageManifest);
|
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() {
|
public String filename() {
|
||||||
|
|
|
@ -1363,12 +1363,28 @@ public class StructureMapUtilities {
|
||||||
vars.add(VariableMode.INPUT, getInputName(g, StructureMapInputMode.SOURCE, "source"), source);
|
vars.add(VariableMode.INPUT, getInputName(g, StructureMapInputMode.SOURCE, "source"), source);
|
||||||
if (target != null)
|
if (target != null)
|
||||||
vars.add(VariableMode.OUTPUT, getInputName(g, StructureMapInputMode.TARGET, "target"), target);
|
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);
|
executeGroup("", context, map, vars, g, true);
|
||||||
if (target instanceof Element)
|
if (target instanceof Element)
|
||||||
((Element) target).sort();
|
((Element) target).sort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 {
|
private String getInputName(StructureMapGroupComponent g, StructureMapInputMode mode, String def) throws DefinitionException {
|
||||||
String name = null;
|
String name = null;
|
||||||
for (StructureMapGroupInputComponent inp : g.getInput()) {
|
for (StructureMapGroupInputComponent inp : g.getInput()) {
|
||||||
|
|
|
@ -200,5 +200,12 @@ public class TextFile {
|
||||||
return streamToString(new ByteArrayInputStream(bs));
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
// 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 link(String href);
|
||||||
|
public abstract void anchor(String name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -902,6 +902,11 @@ public class XMLWriter extends OutputStreamWriter implements IXMLWriter {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void anchor(String name) {
|
||||||
|
// ignore this
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void decorate(ElementDecoration element) throws IOException {
|
public void decorate(ElementDecoration element) throws IOException {
|
||||||
// nothing...
|
// nothing...
|
||||||
|
|
Loading…
Reference in New Issue