Search in sources :

Example 11 with XMLWriter

use of org.hl7.fhir.utilities.xml.XMLWriter in project org.hl7.fhir.core by hapifhir.

the class XmlParserBase method compose.

/**
 * Compose a resource to a stream, possibly using pretty presentation for a human reader, and maybe a different choice in the xhtml narrative (used in the spec in one place, but should not be used in production)
 * @
 */
public void compose(OutputStream stream, Resource resource, boolean htmlPretty) throws IOException {
    XMLWriter writer = new XMLWriter(stream, "UTF-8");
    writer.setPretty(style == OutputStyle.PRETTY);
    writer.start();
    compose(writer, resource, htmlPretty);
    writer.end();
}
Also used : IXMLWriter(org.hl7.fhir.utilities.xml.IXMLWriter) XMLWriter(org.hl7.fhir.utilities.xml.XMLWriter)

Example 12 with XMLWriter

use of org.hl7.fhir.utilities.xml.XMLWriter in project kindling by HL7.

the class BuildWorkerContext method saveLoinc.

public void saveLoinc(String filename) throws IOException {
    XMLWriter xml = new XMLWriter(new FileOutputStream(filename), "UTF-8");
    xml.setPretty(true);
    xml.setLineType(XMLWriter.LINE_UNIX);
    xml.start();
    xml.enter("loinc");
    List<String> codes = new ArrayList<String>();
    codes.addAll(loincCodes.keySet());
    Collections.sort(codes);
    for (String c : codes) {
        xml.attribute("id", c);
        Concept cc = loincCodes.get(c);
        xml.attribute("short", cc.shortN);
        xml.attribute("long", cc.display);
        xml.element("concept");
    }
    xml.exit("loinc");
    xml.end();
    xml.close();
}
Also used : FileOutputStream(java.io.FileOutputStream) ArrayList(java.util.ArrayList) XMLWriter(org.hl7.fhir.utilities.xml.XMLWriter)

Example 13 with XMLWriter

use of org.hl7.fhir.utilities.xml.XMLWriter in project kindling by HL7.

the class BuildWorkerContext method saveSnomed.

public void saveSnomed(String filename) throws Exception {
    FileOutputStream file = new FileOutputStream(filename);
    XMLWriter xml = new XMLWriter(file, "UTF-8");
    xml.setPretty(true);
    xml.setLineType(XMLWriter.LINE_UNIX);
    xml.start();
    xml.comment("the build tool builds these from the designated snomed server, when it can", true);
    xml.enter("snomed");
    List<String> ids = new ArrayList<String>();
    ids.addAll(snomedCodes.keySet());
    Collections.sort(ids);
    for (String s : ids) {
        xml.attribute("id", s);
        Concept c = snomedCodes.get(s);
        xml.attribute("display", c.display);
        if (c.displays.size() == 0)
            xml.element("concept", null);
        else {
            xml.enter("concept");
            for (String d : c.displays) {
                xml.attribute("value", d);
                xml.element("display", null);
            }
            xml.exit("concept");
        }
    }
    xml.exit("snomed");
    xml.end();
}
Also used : FileOutputStream(java.io.FileOutputStream) ArrayList(java.util.ArrayList) XMLWriter(org.hl7.fhir.utilities.xml.XMLWriter)

Example 14 with XMLWriter

use of org.hl7.fhir.utilities.xml.XMLWriter in project kindling by HL7.

the class SvgGenerator method generate.

public void generate(ResourceDefn resource, String filename, String id) throws Exception {
    this.id = id;
    classes.clear();
    links.clear();
    XMLWriter xml = new XMLWriter(new FileOutputStream(filename), "UTF-8");
    generate(resource, xml);
}
Also used : FileOutputStream(java.io.FileOutputStream) XMLWriter(org.hl7.fhir.utilities.xml.XMLWriter)

Example 15 with XMLWriter

use of org.hl7.fhir.utilities.xml.XMLWriter in project kindling by HL7.

the class SvgGenerator method textForAttribute.

private String[] textForAttribute(ElementDefn e) throws Exception {
    LineStatus ls = new LineStatus();
    // this is a dummary
    XMLWriter xml = new XMLWriter(new ByteArrayOutputStream(), "UTF-8");
    xml.start();
    addAttribute(xml, 0, 0, e, "Element.id", ls, 0, 0);
    ls.close();
    return ls.list.toArray(new String[] {});
}
Also used : ByteArrayOutputStream(java.io.ByteArrayOutputStream) XMLWriter(org.hl7.fhir.utilities.xml.XMLWriter)

Aggregations

XMLWriter (org.hl7.fhir.utilities.xml.XMLWriter)28 IXMLWriter (org.hl7.fhir.utilities.xml.IXMLWriter)22 FileOutputStream (java.io.FileOutputStream)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 ArrayList (java.util.ArrayList)2 ElementDefn (org.hl7.fhir.definitions.model.ElementDefn)2 BindingSpecification (org.hl7.fhir.definitions.model.BindingSpecification)1 DefinedCode (org.hl7.fhir.definitions.model.DefinedCode)1 DefinedStringPattern (org.hl7.fhir.definitions.model.DefinedStringPattern)1 PrimitiveType (org.hl7.fhir.definitions.model.PrimitiveType)1 ProfiledType (org.hl7.fhir.definitions.model.ProfiledType)1 ResourceDefn (org.hl7.fhir.definitions.model.ResourceDefn)1 TypeRef (org.hl7.fhir.definitions.model.TypeRef)1 SpecialElement (org.hl7.fhir.dstu2016may.metamodel.Element.SpecialElement)1 IniFile (org.hl7.fhir.utilities.IniFile)1