private Element getRootElement() { Element eRoot = new Element("rest-client"); // set version attributes to rest-client root tag eRoot.addAttribute(new Attribute("version", Versions.CURRENT)); return eRoot; }
/** * Helper method for addWordInfo(). If the value is not null, * creates an element of the given name and namespace and adds it to the * tokenElement. * * @param tokenElement This is the element to which the newly created element will be added * @param elemName This is the name for the new XML element * @param curNS The current namespace * @param value This is its value */ private static void setSingleElement(Element tokenElement, String elemName, String curNS, String value) { if (value != null) { Element cur = new Element(elemName, curNS); cur.appendChild(value); tokenElement.appendChild(cur); } }
public Object getDocumentNode(Object o) { ParentNode parent = null; if (o instanceof ParentNode) { parent = (ParentNode)o; } else if (o instanceof Node) { parent = ((Node)o).getParent(); } return parent.getDocument(); }
public static void writeRequestCollectionXML(final List<Request> requests, final File f) throws IOException, XMLException { XmlPersistenceWrite xUtl = new XmlPersistenceWrite(); Element eRoot = new Element("request-collection"); eRoot.addAttribute(new Attribute("version", Versions.CURRENT)); for(Request req: requests) { Element e = xUtl.getRequestElement(req); eRoot.appendChild(e); } Document doc = new Document(eRoot); xUtl.writeXML(doc, f); }
public String peekNextChild() { Elements children = currentElement.getChildElements(); if (null == children || children.size() == 0) { return null; } return decodeNode(children.get(0).getLocalName()); } }
private void addFields(Elements eFields, ReqEntityBasePart part) { if(eFields == null) { return; } for(int i=0; i<eFields.size(); i++) { Element eField = eFields.get(i); String name = eField.getChildElements("name").get(0).getValue(); String value = eField.getChildElements("value").get(0).getValue(); part.addField(name, value); } }
/** {@inheritDoc} */ @Override public void print(Annotation annotation, OutputStream os, Options options) throws IOException { Document xmlDoc = annotationToDoc(annotation, options); Serializer ser = new Serializer(os, options.encoding); if (options.pretty) { ser.setIndent(2); } else { ser.setIndent(0); } ser.setMaxLength(0); ser.write(xmlDoc); ser.flush(); }
private String getPartValue(Element e) { if(readVersion.isLessThan(VERSION_SINCE_PART_CONTENT)) { return e.getValue(); } else { Element eContent = e.getChildElements("content").get(0); return eContent.getValue(); } }
protected Document response2XML(final Response bean) throws XMLException { Element respRootElement = getRootElement(); respRootElement.appendChild(getResponseElement(bean)); Document xomDocument = new Document(respRootElement); return xomDocument; }
protected Object getChild(int index) { return currentElement.getChildElements().get(index); }
protected int getChildCount() { return currentElement.getChildElements().size(); }
public String getAttribute(int index) { return currentElement.getAttribute(index).getValue(); }
/** * @since 1.4 */ public XomReader(Document document, NameCoder nameCoder) { super(document.getRootElement(), nameCoder); }
/** * Generates the XML content for a list of OpenIE triples. */ private static void addTriples(Collection<RelationTriple> openieTriples, Element top, String namespaceUri) { for (RelationTriple triple : openieTriples) { top.appendChild(toXML(triple, namespaceUri)); } }
public String toString() { return ( "[xmlns:" + prefix + "=\"" + uri + "\", element=" + element.getLocalName() + "]" ); } }
@Override public String convert(Document original) { return original.toXML(); } }
protected Document request2XML(final Request bean) throws XMLException { Element reqRootElement = getRootElement(); reqRootElement.appendChild(getRequestElement(bean)); Document xomDocument = new Document(reqRootElement); return xomDocument; }
/** * @since 1.2 * @deprecated As of 1.4 use {@link XomReader#XomReader(Element, NameCoder)} instead. */ public XomReader(Document document, XmlFriendlyReplacer replacer) { this(document.getRootElement(), (NameCoder)replacer); }
/** * Generates the XML content for MachineReading entities. */ private static void addEntities(List<EntityMention> entities, Element top, String curNS) { for (EntityMention e: entities) { Element ee = toXML(e, curNS); top.appendChild(ee); } }