/** * Identifies WSDL documents from the {@link DOMForest}. Also identifies the root wsdl document. */ private void identifyRootWsdls() { for (String location : rootDocuments) { Document doc = get(location); if (doc != null) { Element definition = doc.getDocumentElement(); if (definition == null || definition.getLocalName() == null || definition.getNamespaceURI() == null) continue; if (definition.getNamespaceURI().equals(WSDLConstants.NS_WSDL) && definition.getLocalName().equals("definitions")) { rootWsdls.add(location); // set the root wsdl at this point. Root wsdl is one which has wsdl:service in it NodeList nl = definition.getElementsByTagNameNS(WSDLConstants.NS_WSDL, "service"); // TODO:what if there are more than one wsdl with wsdl:service element. Probably such // cases // are rare and we will take any one of them, this logic should still work if (nl.getLength() > 0) rootWSDL = location; } } } // no wsdl with wsdl:service found, throw error if (rootWSDL == null) { StringBuilder strbuf = new StringBuilder(); for (String str : rootWsdls) { strbuf.append(str); strbuf.append('\n'); } errorReceiver.error(null, WsdlMessages.FAILED_NOSERVICE(strbuf.toString())); } }
@SuppressWarnings("element-type-mismatch") public void parseWSDL() { // parse source grammars for (InputSource value : options.getWSDLs()) { String systemID = value.getSystemId(); errorReceiver.pollAbort(); Document dom; Element doc; try { // if there is entity resolver use it if (options.entityResolver != null) { value = options.entityResolver.resolveEntity(null, systemID); } if (value == null) { value = new InputSource(systemID); } dom = parse(value, true); doc = dom.getDocumentElement(); if (doc == null) { continue; } // if its not a WSDL document, retry with MEX if (doc.getNamespaceURI() == null || !doc.getNamespaceURI().equals(WSDLConstants.NS_WSDL) || !doc.getLocalName().equals("definitions")) { throw new SAXParseException( WsdlMessages.INVALID_WSDL( systemID, com.sun.xml.internal.ws.wsdl.parser.WSDLConstants.QNAME_DEFINITIONS, doc.getNodeName(), locatorTable.getStartLocation(doc).getLineNumber()), locatorTable.getStartLocation(doc)); } } catch (FileNotFoundException e) { errorReceiver.error(WsdlMessages.FILE_NOT_FOUND(systemID), e); return; } catch (IOException e) { doc = getFromMetadataResolver(systemID, e); } catch (SAXParseException e) { doc = getFromMetadataResolver(systemID, e); } catch (SAXException e) { doc = getFromMetadataResolver(systemID, e); } if (doc == null) { continue; } NodeList schemas = doc.getElementsByTagNameNS(SchemaConstants.NS_XSD, "schema"); for (int i = 0; i < schemas.getLength(); i++) { if (!inlinedSchemaElements.contains(schemas.item(i))) { inlinedSchemaElements.add((Element) schemas.item(i)); } } } identifyRootWsdls(); }
protected void handleParent(Element e, NameSpaceSymbTable ns) { if (!e.hasAttributes() && e.getNamespaceURI() == null) { return; } xmlattrStack.push(-1); NamedNodeMap attrs = e.getAttributes(); int attrsLength = attrs.getLength(); for (int i = 0; i < attrsLength; i++) { Attr attribute = (Attr) attrs.item(i); String NName = attribute.getLocalName(); String NValue = attribute.getNodeValue(); if (Constants.NamespaceSpecNS.equals(attribute.getNamespaceURI())) { if (!XML.equals(NName) || !Constants.XML_LANG_SPACE_SpecNS.equals(NValue)) { ns.addMapping(NName, NValue, attribute); } } else if (!"id".equals(NName) && XML_LANG_URI.equals(attribute.getNamespaceURI())) { xmlattrStack.addXmlnsAttr(attribute); } } if (e.getNamespaceURI() != null) { String NName = e.getPrefix(); String NValue = e.getNamespaceURI(); String Name; if (NName == null || NName.equals("")) { NName = "xmlns"; Name = "xmlns"; } else { Name = "xmlns:" + NName; } Attr n = e.getOwnerDocument().createAttributeNS("http://www.w3.org/2000/xmlns/", Name); n.setValue(NValue); ns.addMapping(NName, NValue, n); } }
private static String getElementStringRep(Element el) { String result = el.getLocalName(); if (el.getNamespaceURI() != null) { result = el.getNamespaceURI() + ":" + result; } return result; }
private void writeElement(OutputNode thisNode, Element anyElement) throws Exception { thisNode.setName(anyElement.getLocalName()); thisNode.getAttributes().remove("class"); if (!getCurrentNamespace(thisNode).equals(anyElement.getNamespaceURI().toString())) { thisNode.setAttribute("xmlns", anyElement.getNamespaceURI().toString()); thisNode.setReference(anyElement.getNamespaceURI().toString()); } NodeList childList = anyElement.getChildNodes(); boolean childElements = false; for (int i = 0; i < childList.getLength(); i++) { Node n = childList.item(i); if (n instanceof Attr) { thisNode.setAttribute(n.getNodeName(), n.getNodeValue()); } if (n instanceof Element) { childElements = true; Element e = (Element) n; writeElement(thisNode.getChild(e.getLocalName()), e); } } if (anyElement.getNodeValue() != null) { thisNode.setValue(anyElement.getNodeValue()); } // added to work with harmony ElementImpl... getNodeValue doesn't seem to work!!! if (!childElements && anyElement.getTextContent() != null) { thisNode.setValue(anyElement.getTextContent()); } }
/** * Runs the test case. * * @throws Throwable Any uncaught exception causes test to fail */ @TestTargetNew( level = TestLevel.COMPLETE, notes = "", method = "getNamespaceURI", args = {}) public void testGetNamespaceURI() throws Throwable { Document doc; Element element; Element elementNS; Attr attr; Attr attrNS; String elemNSURI; String elemNSURINull; String attrNSURI; String attrNSURINull; String nullNS = null; doc = (Document) load("staff", builder); element = doc.createElementNS(nullNS, "elem"); elementNS = doc.createElementNS("http://www.w3.org/DOM/Test/elem", "qual:qelem"); attr = doc.createAttributeNS(nullNS, "attr"); attrNS = doc.createAttributeNS("http://www.w3.org/DOM/Test/attr", "qual:qattr"); elemNSURI = elementNS.getNamespaceURI(); elemNSURINull = element.getNamespaceURI(); attrNSURI = attrNS.getNamespaceURI(); attrNSURINull = attr.getNamespaceURI(); assertEquals("nodegetnamespaceuri03_elemNSURI", "http://www.w3.org/DOM/Test/elem", elemNSURI); assertNull("nodegetnamespaceuri03_1", elemNSURINull); assertEquals("nodegetnamespaceuri03_attrNSURI", "http://www.w3.org/DOM/Test/attr", attrNSURI); assertNull("nodegetnamespaceuri03_2", attrNSURINull); }
public boolean isValidSOAP() { if (document == null || (document.getNodeType() != Node.DOCUMENT_NODE)) { return false; } Element soapEnvelope = document.getDocumentElement(); try { if (soapEnvelope == null || (soapEnvelope.getNodeType() != Node.ELEMENT_NODE)) { return false; } if (soapEnvelope.getNamespaceURI() != null) { if (!soapEnvelope.getNamespaceURI().equals(NS_URI_SOAP_ENVELOPE)) return false; } if (!soapEnvelope.getNodeName().equals(ELEM_SOAP_ENVELOPE)) return false; NodeList nodeList = soapEnvelope.getElementsByTagName(ELEM_SOAP_HEADER); if (nodeList == null || nodeList.getLength() > 1) { return false; } nodeList = soapEnvelope.getElementsByTagName(ELEM_SOAP_BODY); if (nodeList == null || nodeList.getLength() != 1) { return false; } return true; } catch (Exception ex) { return false; } }
public void testSendRequest_rpc() throws Exception { String requestText = "<env:Envelope xmlns:env='" + SOAPConstants.URI_NS_SOAP_ENVELOPE + "'>" + "<env:Body>" + "<tns:op xmlns:tns='" + BpelConstants.NS_EXAMPLES + "'>" + " <simplePart>wazabi</simplePart>" + " <complexPart>" + " <b on='true'>true</b>" + " <c name='venus'/>" + " <d amount='20'/>" + " <e>30</e>" + " </complexPart>" + "</tns:op>" + "</env:Body>" + "</env:Envelope>"; SOAPMessage soapMessage = MessageFactory.newInstance() .createMessage(null, new ByteArrayInputStream(requestText.getBytes())); Connection connection = integrationControl.getJmsConnection(); connection.start(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); try { SoapHandler soapHandler = createRpcHandler(); soapHandler.sendRequest(soapMessage, session, jbpmContext); PartnerLinkEntry entry = integrationControl.getPartnerLinkEntry(Q_RPC_PORT_TYPE, Q_SERVICE, RPC_PORT); MessageConsumer consumer = session.createConsumer(entry.getDestination()); ObjectMessage message = (ObjectMessage) consumer.receiveNoWait(); Map requestParts = (Map) message.getObject(); // simple part Element simplePart = (Element) requestParts.get("simplePart"); assertEquals("simplePart", simplePart.getLocalName()); assertNull(simplePart.getNamespaceURI()); assertEquals("wazabi", DatatypeUtil.toString(simplePart)); // complex part Element complexPart = (Element) requestParts.get("complexPart"); assertEquals("complexPart", complexPart.getLocalName()); assertNull(complexPart.getNamespaceURI()); assertTrue(complexPart.hasChildNodes()); // message properties assertEquals( rpcPartnerLinkId, message.getLongProperty(IntegrationConstants.PARTNER_LINK_ID_PROP)); assertEquals("op", message.getStringProperty(IntegrationConstants.OPERATION_NAME_PROP)); assertEquals("venus", message.getStringProperty("nameProperty")); assertEquals("30", message.getStringProperty("idProperty")); } finally { session.close(); } }
protected void start(Element element, XSDElementDeclaration declaration) throws SAXException { String uri = element.getNamespaceURI(); String local = element.getLocalName(); String qName = element.getLocalName(); NamespaceSupport namespaces = this.namespaces; // declaration == null -> gml3 envelope encoding test failing // declaration.getSchema() == null -> wfs 2.0 feature collection encoding test failing if (namespaceAware && (declaration == null || declaration.isGlobal() || declaration.getSchema() == null || declaration.getSchema().getElementFormDefault() == XSDForm.QUALIFIED_LITERAL)) { uri = (uri != null) ? uri : namespaces.getURI(""); qName = namespaces.getPrefix(uri) + ":" + qName; } else { uri = ""; } DOMAttributes atts = new DOMAttributes(element.getAttributes(), namespaces); serializer.startElement(uri, local, qName, atts); // write out any text for (int i = 0; i < element.getChildNodes().getLength(); i++) { Node node = (Node) element.getChildNodes().item(i); if (node instanceof Text) { char[] ch = ((Text) node).getData().toCharArray(); serializer.characters(ch, 0, ch.length); } } // write out any child elements for (int i = 0; i < element.getChildNodes().getLength(); i++) { Node node = (Node) element.getChildNodes().item(i); if (node instanceof Element) { Element child = (Element) node; start( child, Schemas.getChildElementDeclaration( declaration, new QName(child.getNamespaceURI(), child.getNodeName()))); end(child); } } // push a new context for children, declaring the default prefix to be the one of this // element this.namespaces.pushContext(); if (uri != null) { this.namespaces.declarePrefix("", uri); } }
private boolean isAIMAnnotation(XmlObject file) { Document document = file.getDocument(); Element documentElement = document.getDocumentElement(); System.out.println( "isAim:" + documentElement.getLocalName() + "," + documentElement.getNamespaceURI()); return documentElement.getLocalName().equals("ImageAnnotation") && (documentElement .getNamespaceURI() .equals("gme://caCORE.caCORE/3.2/edu.northwestern.radiology.AIM") || documentElement .getNamespaceURI() .equals("gme://caCORE/3.2/edu.northwestern.radiology.AIM")); }
private static String compareElements(String path, Element e1, Element e2) { if (!e1.getNamespaceURI().equals(e2.getNamespaceURI())) return "Namespaces differ at " + path + ": " + e1.getNamespaceURI() + "/" + e2.getNamespaceURI(); if (!e1.getLocalName().equals(e2.getLocalName())) return "Names differ at " + path + ": " + e1.getLocalName() + "/" + e2.getLocalName(); path = path + "/" + e1.getLocalName(); String s = compareAttributes(path, e1.getAttributes(), e2.getAttributes()); if (!Utilities.noString(s)) return s; s = compareAttributes(path, e2.getAttributes(), e1.getAttributes()); if (!Utilities.noString(s)) return s; Node c1 = e1.getFirstChild(); Node c2 = e2.getFirstChild(); c1 = skipBlankText(c1); c2 = skipBlankText(c2); while (c1 != null && c2 != null) { if (c1.getNodeType() != c2.getNodeType()) return "node type mismatch in children of " + path + ": " + Integer.toString(e1.getNodeType()) + "/" + Integer.toString(e2.getNodeType()); if (c1.getNodeType() == Node.TEXT_NODE) { if (!normalise(c1.getTextContent()).equals(normalise(c2.getTextContent()))) return "Text differs at " + path + ": " + normalise(c1.getTextContent()) + "/" + normalise(c2.getTextContent()); } else if (c1.getNodeType() == Node.ELEMENT_NODE) { s = compareElements(path, (Element) c1, (Element) c2); if (!Utilities.noString(s)) return s; } c1 = skipBlankText(c1.getNextSibling()); c2 = skipBlankText(c2.getNextSibling()); } if (c1 != null) return "node mismatch - more nodes in source in children of " + path; if (c2 != null) return "node mismatch - more nodes in target in children of " + path; return null; }
private void transferProperties(Node qualifPropsNode, Node tempNode) { // The QualifyingProperties node already has a child element for the current // type of properties. Element existingProps = DOMHelper.getFirstDescendant( (Element) qualifPropsNode, QualifyingProperty.XADES_XMLNS, propsElemName); // The new properties (Signed or Unsigned) were marshalled into the temp // node. Element newProps = DOMHelper.getFirstChildElement(tempNode); Element newSpecificProps = DOMHelper.getFirstChildElement(newProps); do { Element existingSpecificProps = DOMHelper.getFirstDescendant( existingProps, newSpecificProps.getNamespaceURI(), newSpecificProps.getLocalName()); if (null == existingSpecificProps) // No element for these properties. Append the new element to the existing // properties. existingProps.appendChild(newSpecificProps); else // There are properties. Transfer all the new properties into the existing // element. transferChildren(newSpecificProps, existingSpecificProps); newSpecificProps = DOMHelper.getNextSiblingElement(newSpecificProps); } while (newSpecificProps != null); }
/** * Set a property of a resource to a value. * * @param name the property name * @param value the property value * @exception com.ibm.webdav.WebDAVException */ public void setProperty(String name, Element value) throws WebDAVException { // load the properties Document propertiesDocument = resource.loadProperties(); Element properties = propertiesDocument.getDocumentElement(); String ns = value.getNamespaceURI(); Element property = null; if (ns == null) { property = (Element) ((Element) properties).getElementsByTagName(value.getTagName()).item(0); } else { property = (Element) properties.getElementsByTagNameNS(ns, value.getLocalName()).item(0); } if (property != null) { try { properties.removeChild(property); } catch (DOMException exc) { } } properties.appendChild(propertiesDocument.importNode(value, true)); // write out the properties resource.saveProperties(propertiesDocument); }
public boolean handleTypesExtension( com.sun.tools.internal.ws.api.wsdl.TWSDLParserContext context, TWSDLExtensible parent, Element e) { Util.fail("parsing.invalidExtensionElement", e.getTagName(), e.getNamespaceURI()); return false; }
private static boolean isEmotionMLElement(Node n, String localName) { if (n == null || n.getNodeType() != Node.ELEMENT_NODE) { return false; } Element e = (Element) n; return EmotionML.namespaceURI.equals(e.getNamespaceURI()) && localName.equals(n.getLocalName()); }
private boolean handlePortTypeOperation(TWSDLParserContext context, Operation parent, Element e) { context.push(); context.registerNamespaces(e); JAXWSBinding jaxwsBinding = new JAXWSBinding(context.getLocation(e)); for (Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext(); ) { Element e2 = Util.nextElement(iter); if (e2 == null) { break; } if (XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.ENABLE_WRAPPER_STYLE)) { parseWrapperStyle(context, jaxwsBinding, e2); } else if (XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.ENABLE_ASYNC_MAPPING)) { parseAsynMapping(context, jaxwsBinding, e2); } else if (XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.METHOD)) { parseMethod(context, jaxwsBinding, e2); if ((jaxwsBinding.getMethodName() != null) && (jaxwsBinding.getMethodName().getJavaDoc() != null)) { parent.setDocumentation(new Documentation(jaxwsBinding.getMethodName().getJavaDoc())); } } else if (XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.PARAMETER)) { parseParameter(context, jaxwsBinding, e2); } else { Util.fail("parsing.invalidExtensionElement", e2.getTagName(), e2.getNamespaceURI()); return false; } } parent.addExtension(jaxwsBinding); context.pop(); // context.fireDoneParsingEntity( // JAXWSBindingsConstants.JAXWS_BINDINGS, // jaxwsBinding); return true; }
@Override protected void changeItem(UntypedItemXml item) { Element element = getElement(item, property); if (element == null) { throw new CliException("Cannot find element: " + property); } String namespaceURI = element.getNamespaceURI(); String localName = element.getLocalName(); Node parentNode = element.getParentNode(); String parentNamespaceUri = parentNode.getNamespaceURI(); String parentTag = parentNode.getLocalName(); String pathKey = parentNamespaceUri + ":" + parentTag + ":" + namespaceURI + ":" + localName; if ("http://platformlayer.org/service/platformlayer/v1.0:platformLayerService:http://platformlayer.org/service/platformlayer/v1.0:config" .equals(pathKey)) { Element newNode = element.getOwnerDocument().createElementNS(NAMESPACE_URI_CORE, "property"); Element keyNode = element.getOwnerDocument().createElementNS(NAMESPACE_URI_CORE, "key"); keyNode.setTextContent(key); Element valueNode = element.getOwnerDocument().createElementNS(NAMESPACE_URI_CORE, "value"); valueNode.setTextContent(value); newNode.appendChild(keyNode); newNode.appendChild(valueNode); element.appendChild(newNode); } else { throw new UnsupportedOperationException(); } }
@Override protected AbstractBeanDefinition parseInternal(Element elem, ParserContext parserContext) { String elemNsPrefix = elem.getPrefix(), elemNsUri = elem.getNamespaceURI(), elemLocalName = elem.getLocalName(); Class<?> beanClass = this.getBeanClass(elem); AbstractBeanDefinition beanDef = BeanDefinitionBuilder.genericBeanDefinition(beanClass).getRawBeanDefinition(); try { this.parseDefinition( parserContext, parserContext.getRegistry(), elem, elemNsPrefix, elemNsUri, elemLocalName, beanDef); } catch (Exception e) { throw new FatalBeanException( String.format( "Unable to parse bean definition (class=%s) XML element (nsPrefix=%s, nsUri=%s, localName=%s).", beanClass, elemNsPrefix, elemNsUri, elemLocalName), e); } return beanDef; }
public Attribute unmarshal(Object value) { if (value instanceof org.w3c.dom.Element) { org.w3c.dom.Element el = (org.w3c.dom.Element) value; String prefix = el.getPrefix(); String namespace = el.getNamespaceURI(); String local = el.getLocalName(); String child = el.getTextContent(); String typeAsString = el.getAttributeNS(NamespacePrefixMapper.XSI_NS, "type"); String lang = el.getAttributeNS(NamespacePrefixMapper.XML_NS, "lang"); QName type = ((typeAsString == null) || (typeAsString.equals(""))) ? null : stringToQName(typeAsString, el); if (type == null) type = ValueConverter.QNAME_XSD_STRING; if (type.equals(ValueConverter.QNAME_XSD_QNAME)) { QName qn = stringToQName(child, el); // TODO: not robust to prefix not predeclared return pFactory.newAttribute(namespace, local, prefix, qn, type); } else if ((lang == null) || (lang.equals(""))) { return pFactory.newAttribute( namespace, local, prefix, vconv.convertToJava(type, child), type); } else { return pFactory.newAttribute( namespace, local, prefix, pFactory.newInternationalizedString(child, lang), type); } } if (value instanceof JAXBElement) { JAXBElement<?> je = (JAXBElement<?>) value; return pFactory.newAttribute(je.getName(), je.getValue(), vconv); } return null; }
ConfigurationReader() throws Exception { configFileName = System.getProperty("benchmark.config"); if (configFileName == null) { throw new IOException("Property \"benchmark.config\" not set."); } ParamReader reader = new ParamReader(configFileName, true); Document doc = reader.getDocument(); xp = reader.getXPath(); rootElement = doc.getDocumentElement(); String rootNS = rootElement.getNamespaceURI(); String rootName = rootElement.getLocalName(); if (FABANURI.equals(rootNS) && "runConfig".equals(rootName)) { runConfigNode = rootElement; } else { runConfigNode = xp.evaluate("fa:runConfig", rootElement, XPathConstants.NODE); } if (runConfigNode == null) { throw new ConfigurationException("Cannot find <fa:runConfig> element."); } definingClassName = xp.evaluate("@definition", runConfigNode); // if the defining class is null, the benchmark definition needs // to be created based on the information in the driverConfig node. if (definingClassName == null || "".equals(definingClassName.trim())) { definingClassName = createDefinition(runConfigNode); } }
/** * Returns a sibling element that matches a given definition, or <tt>null</tt> if no match is * found. * * @param sibling the sibling DOM element to begin the search * @param target the node to search for * @return the matching element, or <tt>null</tt> if not found */ public static Element findSibling(Element sibling, XmlNode target) { String xmlName = target.getLocalName(); String xmlNamespace = target.getNamespace(); Node node = sibling; if (node == null) { return null; } while ((node = node.getNextSibling()) != null) { if (node.getNodeType() != Node.ELEMENT_NODE) { continue; } Element element = (Element) node; if (!element.getLocalName().equals(xmlName)) { continue; } if (target.isNamespaceAware()) { String ns = element.getNamespaceURI(); if (ns == null) { if (xmlNamespace != null) { continue; } } else { if (!ns.equals(xmlNamespace)) { continue; } } } return element; } return null; }
/** Runs the script. */ public void handleEvent(Event evt) { Element elt = (Element) evt.getCurrentTarget(); // Evaluate the script String script = handlerElement.getTextContent(); if (script.length() == 0) return; DocumentLoader dl = bridgeContext.getDocumentLoader(); AbstractDocument d = (AbstractDocument) handlerElement.getOwnerDocument(); int line = dl.getLineNumber(handlerElement); final String desc = Messages.formatMessage( HANDLER_SCRIPT_DESCRIPTION, new Object[] {d.getDocumentURI(), eventNamespaceURI, eventType, new Integer(line)}); // Find the scripting language String lang = handlerElement.getAttributeNS(null, SVGConstants.SVG_CONTENT_SCRIPT_TYPE_ATTRIBUTE); if (lang.length() == 0) { Element e = elt; while (e != null && (!SVGConstants.SVG_NAMESPACE_URI.equals(e.getNamespaceURI()) || !SVGConstants.SVG_SVG_TAG.equals(e.getLocalName()))) { e = SVGUtilities.getParentElement(e); } if (e == null) return; lang = e.getAttributeNS(null, SVGConstants.SVG_CONTENT_SCRIPT_TYPE_ATTRIBUTE); } runEventHandler(script, evt, lang, desc); }
public static Element[] filterChildElements(Element parent, String ns, String lname) { /* way too noisy if (LOGGER.isDebugEnabled()) { StringBuilder buf = new StringBuilder(100); buf.append("XmlaUtil.filterChildElements: "); buf.append(" ns=\""); buf.append(ns); buf.append("\", lname=\""); buf.append(lname); buf.append("\""); LOGGER.debug(buf.toString()); } */ List<Element> elems = new ArrayList<Element>(); NodeList nlst = parent.getChildNodes(); for (int i = 0, nlen = nlst.getLength(); i < nlen; i++) { Node n = nlst.item(i); if (n instanceof Element) { Element e = (Element) n; if ((ns == null || ns.equals(e.getNamespaceURI())) && (lname == null || lname.equals(e.getLocalName()))) { elems.add(e); } } } return elems.toArray(new Element[elems.size()]); }
/** Removes the scripting listeners from the given element. */ protected void removeScriptingListenersOn(Element elt) { String eltNS = elt.getNamespaceURI(); String eltLN = elt.getLocalName(); if (SVGConstants.SVG_NAMESPACE_URI.equals(eltNS) && SVG12Constants.SVG_HANDLER_TAG.equals(eltLN)) { // For this 'handler' element, remove the handler for the given // event type. AbstractElement tgt = (AbstractElement) elt.getParentNode(); String eventType = elt.getAttributeNS( XMLConstants.XML_EVENTS_NAMESPACE_URI, XMLConstants.XML_EVENTS_EVENT_ATTRIBUTE); String eventNamespaceURI = XMLConstants.XML_EVENTS_NAMESPACE_URI; if (eventType.indexOf(':') != -1) { String prefix = DOMUtilities.getPrefix(eventType); eventType = DOMUtilities.getLocalName(eventType); eventNamespaceURI = ((AbstractElement) elt).lookupNamespaceURI(prefix); } EventListener listener = (EventListener) handlerScriptingListeners.put(eventNamespaceURI, eventType, elt, null); tgt.removeEventListenerNS(eventNamespaceURI, eventType, listener, false); } super.removeScriptingListenersOn(elt); }
protected final void assertName(final QName expected, final Element element) { String localName = element.getLocalName(); String ns = element.getNamespaceURI(); assertEquals(expected.getNamespaceURI(), ns); assertEquals(expected.getLocalPart(), localName); }
/** Tells whether the given SVG document is dynamic. */ public static boolean isDynamicDocument(BridgeContext ctx, Document doc) { Element elt = doc.getDocumentElement(); if ((elt != null) && SVGConstants.SVG_NAMESPACE_URI.equals(elt.getNamespaceURI())) { if (elt.getAttributeNS(null, SVGConstants.SVG_ONABORT_ATTRIBUTE).length() > 0) { return true; } if (elt.getAttributeNS(null, SVGConstants.SVG_ONERROR_ATTRIBUTE).length() > 0) { return true; } if (elt.getAttributeNS(null, SVGConstants.SVG_ONRESIZE_ATTRIBUTE).length() > 0) { return true; } if (elt.getAttributeNS(null, SVGConstants.SVG_ONUNLOAD_ATTRIBUTE).length() > 0) { return true; } if (elt.getAttributeNS(null, SVGConstants.SVG_ONSCROLL_ATTRIBUTE).length() > 0) { return true; } if (elt.getAttributeNS(null, SVGConstants.SVG_ONZOOM_ATTRIBUTE).length() > 0) { return true; } return isDynamicElement(ctx, doc.getDocumentElement()); } return false; }
private void digestExtendedResourceConfig( Element configElement, String defaultSelector, String defaultNamespace, String defaultProfile, String defaultConditionRef) { String configNamespace = configElement.getNamespaceURI(); Smooks configDigester = getExtenededConfigDigester(configNamespace); ExecutionContext executionContext = configDigester.createExecutionContext(); ExtensionContext extentionContext; Element conditionElement = DomUtils.getElement(configElement, "condition", 1); // Create the ExtenstionContext and set it on the ExecutionContext... if (conditionElement != null && (conditionElement.getNamespaceURI().equals(XSD_V10) || conditionElement.getNamespaceURI().equals(XSD_V11))) { extentionContext = new ExtensionContext( this, defaultSelector, defaultNamespace, defaultProfile, digestCondition(conditionElement)); } else if (defaultConditionRef != null) { extentionContext = new ExtensionContext( this, defaultSelector, defaultNamespace, defaultProfile, getConditionEvaluator(defaultConditionRef)); } else { extentionContext = new ExtensionContext(this, defaultSelector, defaultNamespace, defaultProfile, null); } ExtensionContext.setExtensionContext(extentionContext, executionContext); // Filter the extension element through Smooks... configDigester.filterSource(executionContext, new DOMSource(configElement), null); // Copy the created resources from the ExtensionContext and onto the // SmooksResourceConfigurationList... List<SmooksResourceConfiguration> resources = extentionContext.getResources(); for (SmooksResourceConfiguration resource : resources) { resourcelist.add(resource); } }
/** * @param context * @param parent * @param e */ private boolean parseGlobalJAXWSBindings( TWSDLParserContext context, TWSDLExtensible parent, Element e) { context.push(); context.registerNamespaces(e); JAXWSBinding jaxwsBinding = getJAXWSExtension(parent); if (jaxwsBinding == null) { jaxwsBinding = new JAXWSBinding(context.getLocation(e)); } String attr = XmlUtil.getAttributeOrNull(e, JAXWSBindingsConstants.WSDL_LOCATION_ATTR); if (attr != null) { jaxwsBinding.setWsdlLocation(attr); } attr = XmlUtil.getAttributeOrNull(e, JAXWSBindingsConstants.NODE_ATTR); if (attr != null) { jaxwsBinding.setNode(attr); } attr = XmlUtil.getAttributeOrNull(e, JAXWSBindingsConstants.VERSION_ATTR); if (attr != null) { jaxwsBinding.setVersion(attr); } for (Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext(); ) { Element e2 = Util.nextElement(iter); if (e2 == null) { break; } if (XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.PACKAGE)) { parsePackage(context, jaxwsBinding, e2); if ((jaxwsBinding.getJaxwsPackage() != null) && (jaxwsBinding.getJaxwsPackage().getJavaDoc() != null)) { ((Definitions) parent) .setDocumentation(new Documentation(jaxwsBinding.getJaxwsPackage().getJavaDoc())); } } else if (XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.ENABLE_WRAPPER_STYLE)) { parseWrapperStyle(context, jaxwsBinding, e2); } else if (XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.ENABLE_ASYNC_MAPPING)) { parseAsynMapping(context, jaxwsBinding, e2); } // else if(XmlUtil.matchesTagNS(e2, // JAXWSBindingsConstants.ENABLE_ADDITIONAL_SOAPHEADER_MAPPING)){ // parseAdditionalSOAPHeaderMapping(context, jaxwsBinding, e2); // } else if (XmlUtil.matchesTagNS(e2, JAXWSBindingsConstants.ENABLE_MIME_CONTENT)) { parseMimeContent(context, jaxwsBinding, e2); } else { Util.fail("parsing.invalidExtensionElement", e2.getTagName(), e2.getNamespaceURI()); return false; } } parent.addExtension(jaxwsBinding); context.pop(); // context.fireDoneParsingEntity( // JAXWSBindingsConstants.JAXWS_BINDINGS, // jaxwsBinding); return true; }
protected void processToken(SoapMessage message) { Header h = findSecurityHeader(message, false); if (h == null) { return; } boolean utWithCallbacks = MessageUtils.getContextualBoolean(message, SecurityConstants.VALIDATE_TOKEN, true); Element el = (Element) h.getObject(); Element child = DOMUtils.getFirstElement(el); while (child != null) { if (SPConstants.USERNAME_TOKEN.equals(child.getLocalName()) && WSConstants.WSSE_NS.equals(child.getNamespaceURI())) { try { Principal principal = null; Subject subject = null; if (utWithCallbacks) { final WSSecurityEngineResult result = validateToken(child, message); principal = (Principal) result.get(WSSecurityEngineResult.TAG_PRINCIPAL); subject = (Subject) result.get(WSSecurityEngineResult.TAG_SUBJECT); } else { boolean bspCompliant = isWsiBSPCompliant(message); principal = parseTokenAndCreatePrincipal(child, bspCompliant); WSS4JTokenConverter.convertToken(message, principal); } SecurityContext sc = message.get(SecurityContext.class); if (sc == null || sc.getUserPrincipal() == null) { if (subject != null && principal != null) { message.put(SecurityContext.class, createSecurityContext(principal, subject)); } else if (principal instanceof UsernameTokenPrincipal) { UsernameTokenPrincipal utPrincipal = (UsernameTokenPrincipal) principal; String nonce = null; if (utPrincipal.getNonce() != null) { nonce = Base64.encode(utPrincipal.getNonce()); } subject = createSubject( utPrincipal.getName(), utPrincipal.getPassword(), utPrincipal.isPasswordDigest(), nonce, utPrincipal.getCreatedTime()); message.put(SecurityContext.class, createSecurityContext(utPrincipal, subject)); } } if (principal instanceof UsernameTokenPrincipal) { storeResults((UsernameTokenPrincipal) principal, message); } } catch (WSSecurityException ex) { throw new Fault(ex); } catch (Base64DecodingException ex) { throw new Fault(ex); } } child = DOMUtils.getNextElement(child); } }
@Override public void putConfigurationFragment(Element fragment, boolean shared) throws IllegalArgumentException { if (fragment.getNamespaceURI() == null || fragment.getNamespaceURI().length() == 0) { throw new IllegalArgumentException("Illegal elementName and/or namespace"); // NOI18N } if (fragment .getLocalName() .equals(helper.getType().getPrimaryConfigurationDataElementName(shared)) && fragment .getNamespaceURI() .equals(helper.getType().getPrimaryConfigurationDataElementNamespace(shared))) { throw new IllegalArgumentException( "elementName + namespace reserved for project's primary configuration data"); // NOI18N } helper.putConfigurationFragment(fragment, shared); }