List of usage examples for org.w3c.dom Element getLocalName
public String getLocalName();
From source file:org.jbpm.bpel.integration.soap.SoapUtil.java
public static void copyChildElement(SOAPElement parent, Element source) throws SOAPException { String localName = source.getLocalName(); String prefix = source.getPrefix(); String namespaceURI = source.getNamespaceURI(); Name targetName;/*from ww w .j a v a 2 s . c om*/ SOAPEnvelope envelope = findEnvelope(parent); if (prefix == null || prefix.length() == 0) { // source has no prefix, distinguish between no namespace and default namespace if (namespaceURI == null || namespaceURI.length() == 0) { // no namespace targetName = envelope.createName(localName); if (traceEnabled) log.trace("appended element: " + localName); } else { // default namespace, look for existing prefix at target prefix = getPrefix(namespaceURI, parent); // no prefix for that namespace? if (prefix == null) { prefix = XmlUtil.generatePrefix(DEFAULT_NAMESPACE_PREFIX, source); } // BPEL-195 source maps prefix to another URI? else if (!namespaceURI.equals(source.getAttributeNS(BpelConstants.NS_XMLNS, prefix))) { prefix = XmlUtil.generatePrefix(prefix, source); } targetName = envelope.createName(localName, prefix, namespaceURI); if (traceEnabled) log.trace("added child element: {" + namespaceURI + '}' + prefix + ':' + localName); } } else { // source has prefix targetName = envelope.createName(localName, prefix, namespaceURI); if (traceEnabled) log.trace("added child element: {" + namespaceURI + '}' + prefix + ':' + localName); } SOAPElement target; if (parent instanceof SOAPBody) { /* * jboss-ws4ee throws ClassCastException upon calling the remote endpoint if child elements * other than SOAPBodyElements are added to SOAPBody */ SOAPBody body = (SOAPBody) parent; target = body.addBodyElement(targetName); } else target = parent.addChildElement(targetName); // namespaces copyNamespaces(target, source); ensureOwnNamespaceDeclared(target); // attributes copyAttributes(target, source); // child nodes copyChildNodes(target, source); }
From source file:org.jbpm.bpel.xml.BpelReader.java
public Activity readActivity(Element activityElem, CompositeActivity parent) { if (activityElem == null) { // patch the missing activity return new Empty(); }// w ww . j ava2 s .c om ActivityReader parser = (ActivityReader) activityReaders.get(activityElem.getLocalName()); return parser.read(activityElem, parent); }
From source file:org.jbpm.bpel.xml.DeploymentDescriptorReader.java
protected ServiceCatalog readServiceCatalogs(Element catalogsElem, String documentBaseURI) { ArrayList catalogs = new ArrayList(); for (Iterator i = XmlUtil.getElements(catalogsElem, BpelConstants.NS_DEPLOYMENT_DESCRIPTOR); i.hasNext();) { Element catalogElem = (Element) i.next(); ServiceCatalogReader catalogReader = getCatalogReader(catalogElem.getLocalName()); if (catalogReader != null) { ServiceCatalog catalog = catalogReader.read(catalogElem, documentBaseURI); catalogs.add(catalog);// w w w. j av a2s . c o m } else problemHandler.add(new ParseProblem("unrecognized service catalog", catalogElem)); } ServiceCatalog resultingCatalog; switch (catalogs.size()) { case 0: resultingCatalog = null; break; case 1: resultingCatalog = (ServiceCatalog) catalogs.get(0); break; default: resultingCatalog = new CompositeCatalog(catalogs); } return resultingCatalog; }
From source file:org.jbpm.bpel.xml.util.XmlUtil.java
public static String toTraceString(Element elem) { String namespace = elem.getNamespaceURI(); String localName = elem.getLocalName(); // easy way out: no namespace if (namespace == null || namespace.length() == 0) return localName; StringBuffer traceBuffer = new StringBuffer(namespace.length() + localName.length()); traceBuffer.append('{').append(namespace).append('}'); String prefix = elem.getPrefix(); if (prefix != null && prefix.length() > 0) traceBuffer.append(prefix).append(':'); return traceBuffer.append(localName).toString(); }
From source file:org.jcp.xml.dsig.internal.dom.DOMReference.java
/** * Creates a <code>DOMReference</code> from an element. * * @param refElem a Reference element/* w ww .j a va 2 s . c o m*/ */ public DOMReference(Element refElem, XMLCryptoContext context, Provider provider) throws MarshalException { // unmarshal Transforms, if specified Element nextSibling = DOMUtils.getFirstChildElement(refElem); List<Transform> transforms = new ArrayList<Transform>(5); if (nextSibling.getLocalName().equals("Transforms")) { Element transformElem = DOMUtils.getFirstChildElement(nextSibling); while (transformElem != null) { transforms.add(new DOMTransform(transformElem, context, provider)); transformElem = DOMUtils.getNextSiblingElement(transformElem); } nextSibling = DOMUtils.getNextSiblingElement(nextSibling); } // unmarshal DigestMethod Element dmElem = nextSibling; this.digestMethod = DOMDigestMethod.unmarshal(dmElem); // unmarshal DigestValue try { Element dvElem = DOMUtils.getNextSiblingElement(dmElem); this.digestValue = Base64.decode(dvElem); } catch (Base64DecodingException bde) { throw new MarshalException(bde); } // unmarshal attributes this.uri = DOMUtils.getAttributeValue(refElem, "URI"); this.id = DOMUtils.getAttributeValue(refElem, "Id"); if (this.id != null) { DOMCryptoContext dcc = (DOMCryptoContext) context; dcc.setIdAttributeNS(refElem, null, "Id"); } this.type = DOMUtils.getAttributeValue(refElem, "Type"); this.here = refElem.getAttributeNodeNS(null, "URI"); this.refElem = refElem; this.transforms = transforms; this.allTransforms = transforms; this.appliedTransformData = null; this.provider = provider; }
From source file:org.jcp.xml.dsig.internal.dom.DOMXMLSignature.java
/** * Creates a <code>DOMXMLSignature</code> from XML. * * @param sigElem Signature element/*from ww w . j a va2 s.c om*/ * @throws MarshalException if XMLSignature cannot be unmarshalled */ public DOMXMLSignature(Element sigElem, XMLCryptoContext context, Provider provider) throws MarshalException { localSigElem = sigElem; ownerDoc = localSigElem.getOwnerDocument(); // get Id attribute, if specified id = DOMUtils.getAttributeValue(localSigElem, "Id"); // unmarshal SignedInfo Element siElem = DOMUtils.getFirstChildElement(localSigElem); si = new DOMSignedInfo(siElem, context, provider); // unmarshal SignatureValue Element sigValElem = DOMUtils.getNextSiblingElement(siElem); sv = new DOMSignatureValue(sigValElem, context); // unmarshal KeyInfo, if specified Element nextSibling = DOMUtils.getNextSiblingElement(sigValElem); if (nextSibling != null && nextSibling.getLocalName().equals("KeyInfo")) { ki = new DOMKeyInfo(nextSibling, context, provider); nextSibling = DOMUtils.getNextSiblingElement(nextSibling); } // unmarshal Objects, if specified if (nextSibling == null) { objects = Collections.emptyList(); } else { List<XMLObject> tempObjects = new ArrayList<XMLObject>(); while (nextSibling != null) { tempObjects.add(new DOMXMLObject(nextSibling, context, provider)); nextSibling = DOMUtils.getNextSiblingElement(nextSibling); } objects = Collections.unmodifiableList(tempObjects); } }
From source file:org.kalypso.ui.wizard.shape.LoadStyleJob.java
private Object[] loadStyles() throws CoreException { final IPath stylePath = m_data.getStyleFile().getPath(); if (stylePath == null || stylePath.isEmpty()) return ImportShapeFileData.EMPTY_STYLES; final IFile styleFile = ResourcesPlugin.getWorkspace().getRoot().getFile(stylePath); if (styleFile == null || !styleFile.exists()) return ImportShapeFileData.EMPTY_STYLES; try {// w w w . j a va2 s . c om // FIXME: use SLDFactory readStyle instead final Document doc = XMLTools.parse(styleFile); final Element documentElement = doc.getDocumentElement(); if (StyledLayerDescriptor.ELEMENT_STYLEDLAYERDESCRIPTOR.equals(documentElement.getLocalName())) { final URL context = ResourceUtilities.createURL(styleFile); final StyledLayerDescriptor styledLayerDescriptor = SLDFactory.createStyledLayerDescriptor(context, documentElement); final Layer[] layers = styledLayerDescriptor.getLayers(); final Collection<Style> allStyles = new ArrayList<>(); for (final Layer layer : layers) { final Style[] styles = layer.getStyles(); for (final Style style : styles) allStyles.add(style); } return allStyles.toArray(new Style[allStyles.size()]); } else if (FeatureTypeStyle.ELEMENT_FEATURETYPESTYLE.equals(documentElement.getLocalName())) return ImportShapeFileData.FEATURETYPE_STYLES; else return ArrayUtils.EMPTY_OBJECT_ARRAY; } catch (final Exception e) { final IStatus status = new Status(IStatus.ERROR, KalypsoAddLayerPlugin.getId(), Messages.getString("LoadStyleJob_1"), e); //$NON-NLS-1$ KalypsoAddLayerPlugin.getDefault().getLog().log(status); throw new CoreException(status); } }
From source file:org.kalypsodeegree.xml.XMLTools.java
/** * Returns the specified child element of the given elemen. If there are more than one with the same name, the first * one is returned./*from w w w . ja v a 2 s . co m*/ * <p> * * @param name * name of the child element * @param namespace * namespace of the child element * @param node * current element * @return the element or null, if it is missing * @throws XMLParsingException * specified child element is missing and required is true */ public static Element getRequiredChildByName(final String name, final String namespace, final Node node) throws XMLParsingException { final NodeList nl = node.getChildNodes(); Element element = null; Element result = null; if (nl != null && nl.getLength() > 0) { for (int i = 0; i < nl.getLength(); i++) { if (nl.item(i) instanceof Element) { element = (Element) nl.item(i); final String s = element.getNamespaceURI(); if (s == null && namespace == null || namespace != null && namespace.equals(s)) { if (element.getLocalName().equals(name)) { result = element; break; } } } } } if (result == null) { throw new XMLParsingException( "Required child-element '" + name + "' of element '" + node.getNodeName() + "' is missing!"); } return result; }
From source file:org.kalypsodeegree.xml.XMLTools.java
/** * Returns the specified child element of the given elemen. If there are more than one with the same name, the first * one is returned.//from w ww. j av a 2s . c o m * <p> * * @param name * name of the child element * @param namespace * namespace of the child element * @param node * current element * @return the element or null, if it is missing */ public static Element getChildByName(final String name, final String namespace, final Node node) { final NodeList nl = node.getChildNodes(); if (nl != null && nl.getLength() > 0) { for (int i = 0; i < nl.getLength(); i++) { if (nl.item(i) instanceof Element) { final Element element = (Element) nl.item(i); final String s = element.getNamespaceURI(); if (s == null && namespace == null || namespace != null && namespace.equals(s)) { if (element.getLocalName().equals(name)) return element; } } } } return null; }
From source file:org.kalypsodeegree.xml.XMLTools.java
/** * Returns the specified child elements of the given element. * <p>/*ww w . j ava 2s.c o m*/ * * @param name * name of the child elements * @param namespace * namespace of the child elements * @param node * current element * @return the list of matching child elements */ public static ElementList getChildElementsByName(final String name, final String namespace, final Node node) { final NodeList nl = node.getChildNodes(); Element element = null; final ElementList elementList = new ElementList(); if (nl != null && nl.getLength() > 0) { for (int i = 0; i < nl.getLength(); i++) { if (nl.item(i) instanceof Element) { element = (Element) nl.item(i); final String s = element.getNamespaceURI(); if (s == null && namespace == null || namespace != null && namespace.equals(s)) { if (element.getLocalName().equals(name)) { elementList.addElement(element); } } } } } return elementList; }