public String getAttributeNamespaceUri(Object o) { return (isAttribute(o) ? ((Attribute)o).getNamespaceURI() : null); }
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; }
/** * Get the URI part of the name of this node. This is the URI corresponding * to the prefix, or the URI of the default namespace if appropriate. * * @return The URI of the namespace of this node. For an unnamed node, or * for a node with an empty prefix, return an empty string. */ public String getURI() { switch (nodeKind) { case Type.ELEMENT: return ((Element) node).getNamespaceURI(); case Type.ATTRIBUTE: return ((Attribute) node).getNamespaceURI(); default: return ""; } }
/** * Get the URI part of the name of this node. This is the URI corresponding * to the prefix, or the URI of the default namespace if appropriate. * * @return The URI of the namespace of this node. For an unnamed node, or * for a node with an empty prefix, return an empty string. */ public String getURI() { switch (nodeKind) { case Type.ELEMENT: return ((Element) node).getNamespaceURI(); case Type.ATTRIBUTE: return ((Attribute) node).getNamespaceURI(); default: return ""; } }
/** * Get the URI part of the name of this node. This is the URI corresponding * to the prefix, or the URI of the default namespace if appropriate. * * @return The URI of the namespace of this node. For an unnamed node, or * for a node with an empty prefix, return an empty string. */ public String getURI() { switch (nodeKind) { case Type.ELEMENT: return ((Element) node).getNamespaceURI(); case Type.ATTRIBUTE: return ((Attribute) node).getNamespaceURI(); default: return ""; } }
public XmlName(Attribute attribute) { this.prefix = attribute.getNamespacePrefix(); this.localName = attribute.getLocalName(); this.namespace = attribute.getNamespaceURI(); }
public XmlName(Attribute attribute) { this.prefix = attribute.getNamespacePrefix(); this.localName = attribute.getLocalName(); this.namespace = attribute.getNamespaceURI(); }
public XmlName(Attribute attribute) { this.prefix = attribute.getNamespacePrefix(); this.localName = attribute.getLocalName(); this.namespace = attribute.getNamespaceURI(); }
/** recursively delete all non-default and non-cml attributes * i.e. any attribute with explicit non-cml namespace * includes cmlx * * @param element */ public static void removeNonCMLAttributes(CMLElement element) { List<Attribute> attributes = new ArrayList<Attribute>(); for (int i = 0; i < element.getAttributeCount(); i++) { Attribute attribute = element.getAttribute(i); String namespaceURI = attribute.getNamespaceURI(); if (namespaceURI != null && !namespaceURI.equals("") && !namespaceURI.equals(CMLConstants.CML_NS)) { attributes.add(attribute); } } for (Attribute attribute : attributes) { attribute.detach(); } List<CMLElement> childElementList = element.getChildCMLElements(); for (CMLElement childElement : childElementList) { removeNonCMLAttributes(childElement); } } public static Document stripDTDAndOtherProblematicXMLHeadings(String s) throws IOException {
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 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)); }
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)); }
protected void processUnexpectedAttributes(Element element, List<SwordValidationInfo> attributeItems) { int attributeCount = element.getAttributeCount(); Attribute attribute = null; for (int i = 0; i < attributeCount; i++) { attribute = element.getAttribute(i); XmlName attributeName = new XmlName(attribute.getNamespacePrefix(), attribute.getLocalName(), attribute.getNamespaceURI()); SwordValidationInfo info = new SwordValidationInfo(xmlName, attributeName, SwordValidationInfo.UNKNOWN_ATTRIBUTE, SwordValidationInfoType.INFO); info.setContentDescription(attribute.getValue()); attributeItems.add(info); } }
protected void processUnexpectedAttributes(Element element, List<SwordValidationInfo> attributeItems) { int attributeCount = element.getAttributeCount(); Attribute attribute = null; for( int i = 0; i < attributeCount; i++ ) { attribute = element.getAttribute(i); XmlName attributeName = new XmlName(attribute.getNamespacePrefix(), attribute.getLocalName(), attribute.getNamespaceURI()); SwordValidationInfo info = new SwordValidationInfo(xmlName, attributeName, SwordValidationInfo.UNKNOWN_ATTRIBUTE, SwordValidationInfoType.INFO); info.setContentDescription(attribute.getValue()); attributeItems.add(info); } }
protected void processUnexpectedAttributes(Element element, ArrayList<SwordValidationInfo> attributeItems) { int attributeCount = element.getAttributeCount(); Attribute attribute = null; for( int i = 0; i < attributeCount; i++ ) { attribute = element.getAttribute(i); XmlName attributeName = new XmlName(attribute.getNamespacePrefix(), attribute.getLocalName(), attribute.getNamespaceURI()); SwordValidationInfo info = new SwordValidationInfo(xmlName, attributeName, SwordValidationInfo.UNKNOWN_ATTRIBUTE, SwordValidationInfoType.INFO); info.setContentDescription(attribute.getValue()); attributeItems.add(info); } }
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); }
/** * This method overrides the XmlElement definition so that it can allow * the definition of the href attribute. All other attributes are * shown as 'Unknown Attribute' info elements. * * @param element The element that contains the attributes * @param info The info object that will hold the validation info. */ @Override protected void processUnexpectedAttributes(Element element, SwordValidationInfo info) { int attributeCount = element.getAttributeCount(); Attribute attribute = null; for (int i = 0; i < attributeCount; i++) { attribute = element.getAttribute(i); if (!ATTRIBUTE_HREF_NAME.getLocalName().equals(attribute.getQualifiedName())) { XmlName attributeName = new XmlName(attribute.getNamespacePrefix(), attribute.getLocalName(), attribute.getNamespaceURI()); SwordValidationInfo item = new SwordValidationInfo(xmlName, attributeName, SwordValidationInfo.UNKNOWN_ATTRIBUTE, SwordValidationInfoType.INFO); item.setContentDescription(attribute.getValue()); info.addUnmarshallAttributeInfo(item); } } }
/** * Add the information to the unmarshall attribute section of the specified * info object. * * @param element XML element to process * @param info validation information item about elements/attributes */ protected void processUnexpectedAttributes(Element element, SwordValidationInfo info) { int attributeCount = element.getAttributeCount(); Attribute attribute = null; for (int i = 0; i < attributeCount; i++) { attribute = element.getAttribute(i); XmlName attributeName = new XmlName(attribute.getNamespacePrefix(), attribute.getLocalName(), attribute.getNamespaceURI()); SwordValidationInfo item = new SwordValidationInfo(xmlName, attributeName, SwordValidationInfo.UNKNOWN_ATTRIBUTE, SwordValidationInfoType.INFO); item.setContentDescription(attribute.getValue()); info.addUnmarshallAttributeInfo(item); } }
/** * Add the information to the unmarshall attribute section of the specified * info object. * * @param element * @param info */ protected void processUnexpectedAttributes(Element element, SwordValidationInfo info) { int attributeCount = element.getAttributeCount(); Attribute attribute = null; for( int i = 0; i < attributeCount; i++ ) { attribute = element.getAttribute(i); XmlName attributeName = new XmlName(attribute.getNamespacePrefix(), attribute.getLocalName(), attribute.getNamespaceURI()); SwordValidationInfo item = new SwordValidationInfo(xmlName, attributeName, SwordValidationInfo.UNKNOWN_ATTRIBUTE, SwordValidationInfoType.INFO); item.setContentDescription(attribute.getValue()); info.addUnmarshallAttributeInfo(item); } }
/** * Add the information to the unmarshall attribute section of the specified * info object. * * @param element * @param info */ protected void processUnexpectedAttributes(Element element, SwordValidationInfo info) { int attributeCount = element.getAttributeCount(); Attribute attribute = null; for( int i = 0; i < attributeCount; i++ ) { attribute = element.getAttribute(i); XmlName attributeName = new XmlName(attribute.getNamespacePrefix(), attribute.getLocalName(), attribute.getNamespaceURI()); SwordValidationInfo item = new SwordValidationInfo(xmlName, attributeName, SwordValidationInfo.UNKNOWN_ATTRIBUTE, SwordValidationInfoType.INFO); item.setContentDescription(attribute.getValue()); info.addUnmarshallAttributeInfo(item); } }