use of org.xmlpull.infoset.XmlAttribute in project airavata by apache.
the class WSDLUtil method replaceAttributeValue.
/**
* @param element
* @param name
* @param oldValue
* @param newValue
*/
public static void replaceAttributeValue(XmlElement element, String name, String oldValue, String newValue) {
XmlAttribute attribute = element.attribute(name);
if (null != attribute && oldValue.equals(attribute.getValue())) {
element.removeAttribute(attribute);
element.setAttributeValue(name, newValue);
}
Iterable iterator = element.children();
for (Object object : iterator) {
if (object instanceof XmlElement) {
replaceAttributeValue((XmlElement) object, name, oldValue, newValue);
}
}
}
use of org.xmlpull.infoset.XmlAttribute in project airavata by apache.
the class WSDLUtil method attributeExist.
public static boolean attributeExist(XmlElement element, String name, String value) {
XmlAttribute attribute = element.attribute(name);
if (null != attribute && value.equals(attribute.getValue())) {
return true;
}
Iterable iterator = element.children();
boolean ret = false;
for (Object object : iterator) {
if (object instanceof XmlElement) {
ret = ret || attributeExist((XmlElement) object, name, value);
}
}
return ret;
}
use of org.xmlpull.infoset.XmlAttribute in project airavata by apache.
the class BasicTypeMapping method getSimpleTypeIndex.
public static int getSimpleTypeIndex(XmlElement element) {
XmlAttribute type = element.attribute(STR_TYPE);
if (null == type) {
return -1;
}
String typeQNameString = type.getValue();
String typeName = XMLUtil.getLocalPartOfQName(typeQNameString);
String prefix = XMLUtil.getPrefixOfQName(typeQNameString);
XmlNamespace namespace = element.lookupNamespaceByPrefix(prefix);
if (namespace == null) {
return -1;
}
QName typeQname = new QName(namespace.getName(), typeName, prefix);
int simpleTypeIndex = getSimpleTypeIndex(typeQname);
if (-1 == simpleTypeIndex) {
return -1;
}
XmlAttribute maxOccurs = element.attribute(STR_MAX_OCCURS);
if (maxOccurs != null && STR_UNBOUNDED.equals(maxOccurs.getValue())) {
// this is the comvention the arraytype index is simplextye index + NUM
return NUM + simpleTypeIndex;
} else {
return simpleTypeIndex;
}
}
use of org.xmlpull.infoset.XmlAttribute in project airavata by apache.
the class WSDLUtil method getNamespaces.
public static List<XmlNamespace> getNamespaces(XmlElement element) {
LinkedList<XmlNamespace> namespaces = new LinkedList<XmlNamespace>();
namespaces.add(element.getNamespace());
Iterable<XmlAttribute> attributes = element.attributes();
for (XmlAttribute xmlAttribute : attributes) {
if (xmlAttribute.getNamespace() != null && !namespaces.contains(xmlAttribute.getNamespace())) {
namespaces.add(xmlAttribute.getNamespace());
}
int index = xmlAttribute.getValue().indexOf(':');
if (-1 != index) {
String prefix = xmlAttribute.getValue().substring(0, index);
if (element.lookupNamespaceByPrefix(prefix) != null) {
namespaces.add(element.lookupNamespaceByPrefix(prefix));
}
}
}
Iterable children = element.children();
for (Object object : children) {
if (object instanceof XmlElement) {
List<XmlNamespace> newNSs = getNamespaces((XmlElement) object);
for (XmlNamespace xmlNamespace : newNSs) {
if (!namespaces.contains(xmlNamespace)) {
namespaces.add(xmlNamespace);
}
}
}
}
return namespaces;
}
Aggregations