List of usage examples for org.dom4j QName getName
public String getName()
From source file:CallXSLT.java
License:Open Source License
public void generateMyoutput(PipelineContext pipelineContext, XMLReceiver xmlReceiver) throws SAXException { // Define the name of the processor (this is a QName) final QName processorName = new QName("xslt", XMLConstants.OXF_PROCESSORS_NAMESPACE); // Get a factory for this processor final ProcessorFactory processorFactory = ProcessorFactoryRegistry.lookup(processorName); if (processorFactory == null) throw new OXFException("Cannot find processor factory with name '" + processorName.getNamespacePrefix() + ":" + processorName.getName() + "'"); // Create processor final Processor processor = processorFactory.createInstance(); // Connect inputs (one from URL, the other one from a DOM) final URLGenerator urlGeneratorConfig = new URLGenerator("oxf:/apps/java-api/transform.xsl"); PipelineUtils.connect(urlGeneratorConfig, "data", processor, "config"); final Document dataInputDocument = readInputAsDOM4J(pipelineContext, "myinput"); final DOMGenerator domGeneratorData = PipelineUtils.createDOMGenerator(dataInputDocument, "data input", DOMGenerator.ZeroValidity, DOMGenerator.DefaultContext); PipelineUtils.connect(domGeneratorData, "data", processor, "data"); // Connect outputs final DOMSerializer domSerializerData = new DOMSerializer(); PipelineUtils.connect(processor, "data", domSerializerData, "data"); // Candidate for Scala withPipelineContext boolean success = false; final PipelineContext newPipelineContext = new PipelineContext(); // here we decide to use our own PipelineContext try {/*from w w w . j a v a 2 s . com*/ domSerializerData.start(newPipelineContext); final Document result = domSerializerData.runGetDocument(newPipelineContext); success = true; } finally { newPipelineContext.destroy(success); } // Serialize result to output TransformerUtils.writeDom4j(result, xmlReceiver); }
From source file:com.liferay.util.xml.XMLConverter.java
License:Open Source License
public static javax.xml.namespace.QName toJavaxQName(org.dom4j.QName dom4jQName) { javax.xml.namespace.QName javaxQName = new javax.xml.namespace.QName(dom4jQName.getNamespaceURI(), dom4jQName.getName(), dom4jQName.getNamespacePrefix()); return javaxQName; }
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.zimbra.common.soap.Element.java
License:Open Source License
/** Returns the first child <tt>Element</tt> with the given QName. * @throws ServiceException if no matching <tt>Element</tt> is found */ public Element getElement(QName qname) throws ServiceException { return checkNull(qname.getName(), getOptionalElement(qname)); }
From source file:com.zimbra.common.soap.Element.java
License:Open Source License
/** Returns the first child <tt>Element</tt> with the given QName, or * <tt>null</tt> if no matching <tt>Element</tt> is found. */ public Element getOptionalElement(QName qname) { return getOptionalElement(qname.getName()); }
From source file:com.zimbra.cs.dav.caldav.Filter.java
License:Open Source License
protected void parse(Element elem) { for (Object o : elem.elements()) { if (o instanceof Element) { Element e = (Element) o; QName name = e.getQName(); if (canHaveCompFilter() && name.equals(DavElements.E_COMP_FILTER)) mComps.add(new CompFilter(e)); else if (canHavePropFilter() && name.equals(DavElements.E_PROP_FILTER)) mProps.add(new PropFilter(e)); else if (canHaveParamFilter() && name.equals(DavElements.E_PARAM_FILTER)) mParams.add(new ParamFilter(e)); else if (name.equals(DavElements.E_TEXT_MATCH)) mTextMatches.add(new TextMatch(e)); else if (name.equals(DavElements.E_TIME_RANGE)) mTimeRange = new TimeRange(e); else if (name.equals(DavElements.E_IS_NOT_DEFINED)) mIsNotDefinedSet = true; else//from ww w . j a v a 2 s .c o m ZimbraLog.dav.info("unrecognized filter " + name.getNamespaceURI() + ":" + name.getName()); } } }
From source file:com.zimbra.cs.dav.carddav.Filter.java
License:Open Source License
protected void parse(Element elem) { for (Object o : elem.elements()) { if (o instanceof Element) { Element e = (Element) o; QName name = e.getQName(); if (canHavePropFilter() && name.equals(DavElements.CardDav.E_PROP_FILTER)) mProps.add(new PropFilter(e)); else if (canHaveParamFilter() && name.equals(DavElements.CardDav.E_PARAM_FILTER)) mParams.add(new ParamFilter(e, this)); else if (name.equals(DavElements.CardDav.E_TEXT_MATCH)) mTextMatch = new TextMatch(e, this); else if (name.equals(DavElements.CardDav.E_IS_NOT_DEFINED)) mIsNotDefinedSet = true; else//from w ww. jav a 2 s . c o m ZimbraLog.dav.info("unrecognized filter " + name.getNamespaceURI() + ":" + name.getName()); } } }
From source file:com.zimbra.soap.DocumentDispatcher.java
License:Open Source License
public void registerHandler(QName qname, DocumentHandler handler) { if (handler instanceof AdminDocumentHandler) { if (!(includeList == null) && !includeList.isEmpty() && !includeList .contains(String.format("%s::%s", qname.getNamespaceURI(), qname.getQualifiedName()))) { ZimbraLog.soap.debug("skipping %s::%s", qname.getNamespaceURI(), qname.getQualifiedName()); return; }//from w w w .jav a2 s . c om ZimbraLog.soap.debug("Registering %s::%s", qname.getNamespaceURI(), qname.getQualifiedName()); } handlers.put(qname, handler); QName respQName = responses.get(qname); if (respQName == null) { String reqName = qname.getName(); String respName; if (reqName.endsWith(REQUEST_SUFFIX)) { respName = reqName.substring(0, reqName.length() - REQUEST_SUFFIX.length()) + RESPONSE_SUFFIX; } else { respName = reqName + RESPONSE_SUFFIX; } respQName = new QName(respName, qname.getNamespace()); responses.put(qname, respQName); } handler.setResponseQName(respQName); }
From source file:com.zimbra.soap.ProxyTarget.java
License:Open Source License
/** * @param envelope//from w w w .j a va 2 s. c o m * @param authToken * @param qName * @return * @throws ServiceException */ private void disableCsrfFlagInAuthToken(Element envelope, AuthToken authToken, QName qName) throws ServiceException { Element header = envelope.getOptionalElement("Header"); if (header != null) { Element context = header.getOptionalElement(HeaderConstants.CONTEXT); if (context != null) { Element token = context.getOptionalElement(HeaderConstants.E_AUTH_TOKEN); if (token != null) { try { token.setText(authToken.getEncoded()); } catch (AuthTokenException ate) { throw ServiceException.PROXY_ERROR(ate, qName.getName()); } } } } ZimbraLog.soap.debug( "Modified auth token in soap envelope, csrf token flag is disabled. The new envelope : %s", envelope); }
From source file:org.apereo.portal.tenants.TemplateDataTenantOperationsListener.java
License:Apache License
private boolean evaluatePortalDataKeyMatch(Document doc, PortalDataKey pdk) { // Matching is tougher because it's dom4j <> w3c... final QName qname = doc.getRootElement().getQName(); if (!qname.getName().equals(pdk.getName().getLocalPart()) || !qname.getNamespaceURI().equals(pdk.getName().getNamespaceURI())) { // Rule these out straight off... return false; }//from w w w.ja v a 2s .c o m // If the PortalDataKey declares a script // (old method), the document must match it final Attribute s = doc.getRootElement().attribute(PortalDataKey.SCRIPT_ATTRIBUTE_NAME.getLocalPart()); final String script = s != null ? s.getValue() : null; if (pdk.getScript() != null) { // If the pdk declares a script, the data document MUST match it... if (pdk.getScript().equals(script)) { /* * A data document that matches on script need not match on version * as well. It appears that the pdk.version member is overloaded * with two purposes... * * - A numeric version (e.g. 4.0) indicates a match IN THE ABSENCE * OF a script attribute (newer method, below) * - A word (e.g. 'GROUP' or 'MEMBERS') indicates the type of data * the pdk handles, where more than one pdk applies to the data * document */ return true; } else { return false; } } // If the PortalDataKey declares a version BUT NOT a script (new // method), the document must match it final Attribute v = doc.getRootElement().attribute(PortalDataKey.VERSION_ATTRIBUTE_NAME.getLocalPart()); final String version = v != null ? v.getValue() : null; if (pdk.getVersion() != null && pdk.getVersion().equals(version)) { return true; } // This pdk is not a match return false; }