Search in sources :

Example 1 with TagMap

use of com.dexels.navajo.adapter.xmlmap.TagMap in project navajo by Dexels.

the class TmlToXmlMap method appendProperty.

private final void appendProperty(Property p, TagMap parent) throws UserException {
    TagMap property = new TagMap();
    property.setCompact(true);
    property.setName(p.getName());
    property.setText(p.getValue());
    parent.setChild(property);
}
Also used : TagMap(com.dexels.navajo.adapter.xmlmap.TagMap)

Example 2 with TagMap

use of com.dexels.navajo.adapter.xmlmap.TagMap in project navajo by Dexels.

the class TmlToXmlMap method appendMessages.

private final void appendMessages(Message m, TagMap parent) throws UserException {
    if (!m.getMode().equals(Message.MSG_MODE_IGNORE)) {
        // Check for array messages. Only append array children
        TagMap child;
        if (!m.getType().equals(Message.MSG_TYPE_ARRAY)) {
            child = new TagMap();
            child.setCompact(true);
            child.setName(m.getName());
            parent.setChild(child);
        } else {
            child = parent;
        }
        List<Property> allProperties = m.getAllProperties();
        for (int i = 0; i < allProperties.size(); i++) {
            appendProperty(allProperties.get(i), child);
        }
        List<Message> allMessages = m.getAllMessages();
        for (int i = 0; i < allMessages.size(); i++) {
            appendMessages(allMessages.get(i), child);
        }
    }
}
Also used : Message(com.dexels.navajo.document.Message) Property(com.dexels.navajo.document.Property) TagMap(com.dexels.navajo.adapter.xmlmap.TagMap)

Example 3 with TagMap

use of com.dexels.navajo.adapter.xmlmap.TagMap in project navajo by Dexels.

the class XMLMap method main.

public static void main(String[] args) throws Exception {
    XMLMap xml = new XMLMap();
    xml.setStart("xml");
    TagMap district = new TagMap();
    district.setName("district");
    xml.setChild(district);
    district.setName("DISTRIKTJE");
    district.setName("WERKT DIT NOG STEEDS");
    logger.info("child = {}", xml.getChildTag("district", 0));
    TagMap n = new TagMap();
    n.setName("apenoot");
    n.setText("Achterlijke");
    district.setChild(n);
    Binary b = xml.getContent();
    xml.setChildName("district");
    TagMap kind = xml.getChild();
    logger.info("kind = {}", kind.getName());
    StringWriter sw = new StringWriter();
    b.writeBase64(sw);
    logger.info("Result: {}", sw);
}
Also used : StringWriter(java.io.StringWriter) Binary(com.dexels.navajo.document.types.Binary) TagMap(com.dexels.navajo.adapter.xmlmap.TagMap)

Example 4 with TagMap

use of com.dexels.navajo.adapter.xmlmap.TagMap in project navajo by Dexels.

the class XMLMap method parseXML.

private void parseXML(XMLElement e) throws UserException {
    String startName = e.getName();
    this.setName(startName);
    // parse attributes
    Iterator<String> attrib_enum = e.enumerateAttributeNames();
    while (attrib_enum.hasNext()) {
        String key = attrib_enum.next();
        String value = e.getStringAttribute(key);
        if (this.attributes == null) {
            this.attributes = new HashMap<String, String>();
        }
        this.attributes.put(key, value);
    }
    // parse children.
    Vector<XMLElement> v = e.getChildren();
    for (int i = 0; i < v.size(); i++) {
        XMLElement child = v.get(i);
        TagMap childTag = TagMap.parseXMLElement(child, this.compact);
        childTag.setCompact(this.compact);
        this.setChild(childTag);
    }
    // Check for text node.
    if (e.getContent() != null && !e.getContent().equals("")) {
        this.setText(e.getContent());
    }
}
Also used : CaseSensitiveXMLElement(com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement) XMLElement(com.dexels.navajo.document.nanoimpl.XMLElement) TagMap(com.dexels.navajo.adapter.xmlmap.TagMap)

Aggregations

TagMap (com.dexels.navajo.adapter.xmlmap.TagMap)4 Message (com.dexels.navajo.document.Message)1 Property (com.dexels.navajo.document.Property)1 CaseSensitiveXMLElement (com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement)1 XMLElement (com.dexels.navajo.document.nanoimpl.XMLElement)1 Binary (com.dexels.navajo.document.types.Binary)1 StringWriter (java.io.StringWriter)1