List of usage examples for org.dom4j Element getQName
QName getQName();
QName
of this element which represents the local name, the qualified name and the Namespace
. From source file:com.liferay.util.xml.descriptor.WebXML24Descriptor.java
License:Open Source License
@Override public String[] getChildrenOrder(Element parentElement) { String parentName = parentElement.getQName().getName(); String[] childrenOrder = _orderedChildren.get(parentName); if (childrenOrder == null) { childrenOrder = new String[0]; }/* ww w . j av a 2 s.c o m*/ return childrenOrder; }
From source file:com.rayo.core.xml.providers.ColibriProvider.java
License:Apache License
@Override protected Object processElement(Element element) throws Exception { if (COLIBRI_QNAME.equals(element.getQName())) { return buildColibriCommand(element); }// ww w . java 2 s. c om return null; }
From source file:com.rayo.core.xml.providers.HandsetProvider.java
License:Apache License
@Override protected Object processElement(Element element) throws Exception { if (ONHOOK_QNAME.equals(element.getQName())) { return buildOnHookCommand(element); } else if (OFFHOOK_QNAME.equals(element.getQName())) { return buildOffHookCommand(element); } else if (PRIVATE_QNAME.equals(element.getQName())) { return buildPrivateCommand(element); } else if (PUBLIC_QNAME.equals(element.getQName())) { return buildPublicCommand(element); } else if (MUTE_QNAME.equals(element.getQName())) { return buildMuteCommand(element); } else if (UNMUTE_QNAME.equals(element.getQName())) { return buildUnmuteCommand(element); } else if (HOLD_QNAME.equals(element.getQName())) { return buildHoldCommand(element); } else if (TALK_QNAME.equals(element.getQName())) { return buildTalkCommand(element); } else if (UNTALK_QNAME.equals(element.getQName())) { return buildUntalkCommand(element); } else if (ONSPEAKER_QNAME.equals(element.getQName())) { return buildOnSpeakerCommand(element); } else if (OFFSPEAKER_QNAME.equals(element.getQName())) { return buildOffSpeakerCommand(element); } else if (CREATE_SPEAKER_QNAME.equals(element.getQName())) { return buildCreateSpeakerCommand(element); } else if (DESTROY_SPEAKER_QNAME.equals(element.getQName())) { return buildDestroySpeakerCommand(element); } else if (element.getNamespace().equals(RAYO_COMPONENT_NAMESPACE)) { return buildCompleteCommand(element); }//from w ww . j a v a 2 s .co m return null; }
From source file:com.rdvmedecin.proprietes.Properties.java
public Properties() throws DocumentException { File fichier = new File("configuration.xml"); SAXReader reader = new SAXReader(); Document doc = reader.read(fichier); Element root = doc.getRootElement(); List attributes = root.attributes(); List elements = root.elements(); QName qName = root.getQName(); String nom = qName.getName(); // lecture du nom de l'espace de noms String nomEspaceDeNoms = qName.getNamespaceURI(); // lecture du prfixe utilis pour cet espace de nom String nomPrefix = qName.getNamespacePrefix(); String texte = root.getText(); Attribute attribute = (Attribute) attributes.iterator().next(); QName attributeQName = attribute.getQName(); String value = attribute.getValue(); String nomAttribut = attribute.getName(); }
From source file:com.taobao.android.builder.tasks.library.publish.UpdatePomTask.java
License:Apache License
private void updatePomXml(File xml) throws IOException, DocumentException { Map<String, DependencyExtraInfo> extraInfoMap = getExtraMap(); File backupFile = new File(xml.getParentFile(), "pom-backup.xml"); FileUtils.deleteQuietly(backupFile); FileUtils.moveFile(xml, backupFile); XMLWriter writer = null;// XML SAXReader reader = new SAXReader(); OutputFormat format = OutputFormat.createPrettyPrint(); format.setEncoding("UTF-8");// XML?? FileOutputStream fos = new FileOutputStream(xml); try {//from www . j a v a 2 s .c o m Document document = reader.read(backupFile);// ?XML Element dependencies = document.getRootElement().element("dependencies"); if ((null != dependencies) && null != dependencies.elements()) { List<Element> list = dependencies.elements(); for (Element element : list) { List<Element> itemList = element.elements(); String group = ""; String name = ""; String type; String scope; Element scopeEl = null; Element typeEl = null; for (Element element1 : itemList) { if ("groupId".equals(element1.getQName().getName())) { group = element1.getStringValue(); } else if ("artifactId".equals(element1.getQName().getName())) { name = element1.getStringValue(); } else if ("scope".equals(element1.getQName().getName())) { scope = element1.getStringValue(); scopeEl = element1; } else if ("type".equals(element1.getQName().getName())) { type = element1.getStringValue(); typeEl = element1; } } DependencyExtraInfo dependencyExtraInfo = extraInfoMap.get(group + ":" + name); if (null == dependencyExtraInfo) { continue; } //update scope if (StringUtils.isNotEmpty(dependencyExtraInfo.scope)) { if (null != scopeEl) { scopeEl.setText(dependencyExtraInfo.scope); } else { Element newEl = element.addElement("scope"); newEl.setText(dependencyExtraInfo.scope); } } if (StringUtils.isNotEmpty(dependencyExtraInfo.type)) { if (null != typeEl) { typeEl.setText(dependencyExtraInfo.type); } else { Element newEl = element.addElement("type"); newEl.setText(dependencyExtraInfo.type); } } } } writer = new XMLWriter(fos, format); writer.write(document); } finally { if (null != writer) { writer.close(); } IOUtils.closeQuietly(fos); } }
From source file:com.thinkberg.webdav.data.AbstractDavResource.java
License:Apache License
/** * Get property values. This method expects one of either <allprop>, <propnames> or * <prop>. If the element is <prop> it will go through the list of it's children * and request the values. For <allprop> it will get values of all known properties and * <propnames> will return the names of all known properties. * * @param root the root of the result document * @param propertyEl the prop, propname or allprop element * @return the root of the result document *//* w w w . j a v a 2 s . co m*/ public Element getPropertyValues(Element root, Element propertyEl) { // initialize the <propstat> for 200 Element okPropStatEl = root.addElement(TAG_PROPSTAT); Element okPropEl = okPropStatEl.addElement(TAG_PROP); // initialize the <propstat> element for 404 Element failPropStatEl = root.addElement(TAG_PROPSTAT); Element failPropEl = failPropStatEl.addElement(TAG_PROP); if (TAG_ALLPROP.equalsIgnoreCase(propertyEl.getName()) || TAG_PROPNAMES.equalsIgnoreCase(propertyEl.getName())) { boolean ignoreValue = TAG_PROPNAMES.equalsIgnoreCase(propertyEl.getName()); // get all known standard properties for (String propName : ALL_PROPERTIES) { if (!getPropertyValue(okPropEl, propName, ignoreValue)) { failPropEl.addElement(propName); } } // additionally try to add all the custom properties try { FileContent objectContent = object.getContent(); for (String attributeName : objectContent.getAttributeNames()) { if (!getPropertyValue(okPropEl, attributeName, ignoreValue)) { failPropEl.addElement(attributeName); } } } catch (FileSystemException e) { LogFactory.getLog(getClass()) .error(String.format("can't read attribute properties from '%s'", object.getName()), e); } } else { List requestedProperties = propertyEl.elements(); for (Object propertyElObject : requestedProperties) { Element propEl = (Element) propertyElObject; final String nameSpace = propEl.getNamespaceURI(); if (!getPropertyValue(okPropEl, getFQName(nameSpace, propEl.getName()), false)) { failPropEl.addElement(propEl.getQName()); } } } // only add the OK section, if there is content if (okPropEl.elements().size() > 0) { okPropStatEl.addElement(TAG_STATUS).addText(STATUS_200); } else { okPropStatEl.detach(); } // only add the failed section, if there is content if (failPropEl.elements().size() > 0) { failPropStatEl.addElement(TAG_STATUS).addText(STATUS_404); } else { failPropStatEl.detach(); } return root; }
From source file:com.thinkberg.webdav.data.DavResource.java
License:Apache License
protected boolean setPropertyValue(Element root, Element propertyEl) { LogFactory.getLog(getClass()).debug(String.format("[%s].set('%s')", object.getName(), propertyEl.asXML())); if (!ALL_PROPERTIES.contains(propertyEl.getName())) { final String nameSpace = propertyEl.getNamespaceURI(); final String attributeName = getFQName(nameSpace, propertyEl.getName()); try {/*w ww .ja v a 2 s . c o m*/ FileContent objectContent = object.getContent(); final String command = propertyEl.getParent().getParent().getName(); if (TAG_PROP_SET.equals(command)) { StringWriter propertyValueWriter = new StringWriter(); propertyEl.write(propertyValueWriter); propertyValueWriter.close(); objectContent.setAttribute(attributeName, propertyValueWriter.getBuffer().toString()); } else if (TAG_PROP_REMOVE.equals(command)) { objectContent.setAttribute(attributeName, null); } root.addElement(propertyEl.getQName()); return true; } catch (IOException e) { LogFactory.getLog(getClass()).error(String.format("can't store attribute property '%s' = '%s'", attributeName, propertyEl.asXML()), e); } } return false; }
From source file:com.zimbra.common.soap.Soap11Protocol.java
License:Open Source License
public SoapFaultException soapFault(Element fault) { if (!isFault(fault)) return new SoapFaultException("not a soap fault ", fault); Element code = fault.getOptionalElement(FAULTCODE); boolean isReceiversFault = RECEIVER_CODE.equals(code == null ? null : code.getQName()); String reasonValue;/*from w ww. j av a2 s . c o m*/ Element faultString = fault.getOptionalElement(FAULTSTRING); if (faultString != null) reasonValue = faultString.getTextTrim(); else reasonValue = "unknown reason"; Element detail = fault.getOptionalElement(DETAIL); return new SoapFaultException(reasonValue, detail, isReceiversFault, fault); }
From source file:com.zimbra.common.soap.SoapProtocol.java
License:Open Source License
/** * Returns true if this element represents a SOAP envelope *//* w ww .ja va2 s. co m*/ public boolean isEnvelope(Element element) { return mEnvelopeQName.equals(element.getQName()); }
From source file:com.zimbra.common.soap.SoapProtocol.java
License:Open Source License
/** * Returns true if this element represents a SOAP fault */// w w w . jav a 2 s. c o m public boolean isFault(Element element) { return mFaultQName.equals(element.getQName()); }