Refine search
private static void addDependencyInfo(Element depInfo, String rel, boolean isExtra, int source, String sourceWord, Integer sourceCopy, int target, String targetWord, Integer targetCopy, String curNS) { Element depElem = new Element("dep", curNS); depElem.addAttribute(new Attribute("type", rel)); if (isExtra) { depElem.addAttribute(new Attribute("extra", "true")); } Element govElem = new Element("governor", curNS); govElem.addAttribute(new Attribute("idx", Integer.toString(source))); govElem.appendChild(sourceWord); if (sourceCopy != null && sourceCopy > 0) { govElem.addAttribute(new Attribute("copy", Integer.toString(sourceCopy))); } depElem.appendChild(govElem); Element dependElem = new Element("dependent", curNS); dependElem.addAttribute(new Attribute("idx", Integer.toString(target))); dependElem.appendChild(targetWord); if (targetCopy != null && targetCopy > 0) { dependElem.addAttribute(new Attribute("copy", Integer.toString(targetCopy))); } depElem.appendChild(dependElem); depInfo.appendChild(depElem); }
public String getAttribute(int index) { return currentElement.getAttribute(index).getValue(); }
public String getAttributeName(int index) { return decodeAttribute(currentElement.getAttribute(index).getQualifiedName()); }
private static Map<String, Object> buildMetadata(Element fromElem) { Map<String, Object> metadata = Maps.newHashMap(); for (int i = 0; i < fromElem.getAttributeCount(); i++) { Attribute attr = fromElem.getAttribute(i); String uri = attr.getNamespaceURI(); String name = attr.getLocalName(); if (inTmxNamespace(uri)) { String value = attr.getValue(); metadata.put(name, value); } else if (attr.getQualifiedName().equals(XML_LANG)) { String value = attr.getValue(); metadata.put(attr.getQualifiedName(), value); } } List<String> childrenXml = getChildrenAsXml(fromElem); metadata.put(TMX_ELEMENT_CHILDREN, childrenXml); return metadata; }
private void processAttributes(final Element inElement, final Element outElement) { for (int i = 0; i < inElement.getAttributeCount(); i++) { final Attribute attr = inElement.getAttribute(i); final String name = attr.getLocalName(); final String value = attr.getValue(); Element attrElement = new Element(xsdPrefix + ":attribute", XSD_NS_URI); attrElement.addAttribute(new Attribute("name", name)); attrElement.addAttribute(new Attribute("type", xsdPrefix + TypeInferenceUtil.getTypeOfContent(value))); attrElement.addAttribute(new Attribute("use", "required")); outElement.appendChild(attrElement); } }
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; }
private static void addContentTypeCharsetAttribute(ContentType c, Element e) { if(c != null) { e.addAttribute(new Attribute("content-type", c.getContentType())); if(c.getCharset() != null) { e.addAttribute(new Attribute("charset", c.getCharset().name())); } } } }
public DefaultField(Element elm) { this.name = elm.getLocalName(); this.namespace = elm.getNamespaceURI(); this.prefix = elm.getNamespacePrefix(); for(int i = 0; i<elm.getAttributeCount(); i++) { Attribute attribute = elm.getAttribute(i); fields.add(new DefaultField(attribute.getNamespaceURI(), attribute.getNamespacePrefix(), attribute.getLocalName(), attribute.getValue())); } this.content = XmlUtil.innerToString(elm); }
private boolean hasContentTypeMetadata(Element head) { Elements metaChildren = head.getChildElements("meta"); for (int i=0; i < metaChildren.size(); i++) { Element metaChild = metaChildren.get(i); Attribute httpEquiv = metaChild.getAttribute("http-equiv"); if (httpEquiv != null && "content-type".equalsIgnoreCase(httpEquiv.getValue())) { return true; } } return false; } }
/** * from DOM. * * @param att */ public StringArraySTAttribute(Attribute att) { this(att.getLocalName()); this.setCMLValue(att.getValue()); }
private void writeAttribute(Attribute attr) { writeIndex(attr.getNamespacePrefix(), attr.getLocalName()); int type = ATTRIBUTE; if (attr.getNamespaceURI().length() == 0) { type = Util.noNamespace(type); } else { writeIndex(attr.getNamespaceURI()); } writeIndex(attr.getValue()); nodeTokens.add((byte)type); nodeTokens.add(Util.getAttributeTypeCode(attr)); }
/** * Get the local part of the name of this node. This is the name after the * ":" if any. * * @return the local part of the name. For an unnamed node, returns "". */ public String getLocalPart() { switch (nodeKind) { case Type.ELEMENT: return ((Element) node).getLocalName(); case Type.ATTRIBUTE: return ((Attribute) node).getLocalName(); case Type.PROCESSING_INSTRUCTION: return ((ProcessingInstruction) node).getTarget(); default: return ""; } }
/** * Get the display name of this node. For elements and attributes this is * [prefix:]localname. For unnamed nodes, it is an empty string. * * @return The display name of this node. For a node with no name, return an * empty string. */ public String getDisplayName() { switch (nodeKind) { case Type.ELEMENT: return ((Element) node).getQualifiedName(); case Type.ATTRIBUTE: return ((Attribute) node).getQualifiedName(); case Type.PROCESSING_INSTRUCTION: return ((ProcessingInstruction) node).getTarget(); default: return ""; } }
public XmlName(Attribute attribute) { this.prefix = attribute.getNamespacePrefix(); this.localName = attribute.getLocalName(); this.namespace = attribute.getNamespaceURI(); }
public String getNamespaceStringValue(Object o) { if (isElement(o)) { return ((Element)o).getNamespaceURI(); } else if (isAttribute(o)) { return ((Attribute)o).getNamespaceURI(); } else if (o instanceof XPathNamespace) { return ((XPathNamespace)o).getNamespaceURI(); } return null; }
/** * <p> * Returns a string representation of the attribute suitable for * debugging and diagnosis. However, this is not necessarily * a well-formed XML attribute. * </p> * * @return a non-XML string representation of this attribute * * @see java.lang.Object#toString() */ public final String toString() { return "[" + getClass().getName() + ": " + getQualifiedName() + "=\"" + Text.escapeLineBreaksAndTruncate(getValue()) + "\"]"; }
public String getAttributeStringValue(Object o) { return (isAttribute(o) ? ((Attribute)o).getValue() : null); }
public String getNamespacePrefix(Object o) { if (isElement(o)) { return ((Element)o).getNamespacePrefix(); } else if (isAttribute(o)) { return ((Attribute)o).getNamespacePrefix(); } else if (o instanceof XPathNamespace) { return ((XPathNamespace)o).getNamespacePrefix(); } return null; }
public String getAttributeQName(Object o) { return (isAttribute(o) ? ((Attribute)o).getQualifiedName() : null); }