@Override protected void doParse(Element element, BeanDefinitionBuilder builder) { // configure MockFactory builder.addConstructorArgValue(element.getAttribute("class")); builder.addPropertyValue("name", element.getAttribute("id")); builder.addPropertyValue("mockNature", element.getLocalName()); }
private QName getQName(Element el) { QName qname = new QName(el.getNamespaceURI(), el.getLocalName()); System.out.println(qname); return qname; }
/** * Returns true if the element is in XML Signature namespace and the local * name equals the supplied one. * * @param element * @param localName * @return true if the element is in XML Signature namespace and the local name equals * the supplied one */ public static boolean elementIsInSignatureSpace(Element element, String localName) { if (element == null){ return false; } return Constants.SignatureSpecNS.equals(element.getNamespaceURI()) && element.getLocalName().equals(localName); }
/** * <p> * Returns the first child element with the given name. Returns <code>null</code> if not found. * </p> * * @param parent * parent element * @param localName * name of the child element * @return child element, null if not found. */ protected static Element getChildElementByName( Element parent, String localName ) { NodeList children = parent.getChildNodes(); for ( int i = 0; i < children.getLength(); i++ ) { Node node = children.item( i ); if ( node.getNodeType() == Node.ELEMENT_NODE ) { Element element = (Element) node; if ( element.getLocalName().equals( localName ) ) { return element; } } } return null; }
final Node root = doc.getDocumentElement(); final int incomingElementOrder = getElementOrder(elementOrderMap, xmlEntity.getNamespace(), xmlEntity.getType()); final int length = nodes.getLength(); for (int i = 0; i < length; i++) { final Node node = nodes.item(i); final String type = childElement.getLocalName(); final String namespace = childElement.getNamespaceURI();
trimEmptyTextNodes(actual); if (expected.getNodeType() != actual.getNodeType()) { throw new Exception("Different types of nodes: " + expected + " " + actual); Document expectedDoc = (Document) expected; Document actualDoc = (Document) actual; compareNodes(expectedDoc.getDocumentElement(), actualDoc.getDocumentElement(), false); } else if (expected instanceof Element) { Element expectedElement = (Element) expected; if (!expectedElement.getLocalName().equals(actualElement.getLocalName())) { throw new Exception("Element names do not match: " + expectedElement.getLocalName() + " " + actualElement.getLocalName()); String expectedNS = expectedElement.getNamespaceURI(); String actualNS = actualElement.getNamespaceURI(); if ((expectedNS == null && actualNS != null) || (expectedNS != null && !expectedNS.equals(actualNS))) { throw new Exception("Element namespaces names do not match: " + expectedNS + " " + actualNS); String elementName = "{" + expectedElement.getNamespaceURI() + "}" + actualElement.getLocalName(); for (int i = 0; i < expectedChildren.getLength(); i++) { Node expectedChild = expectedChildren.item(i); Node actualChild = actualChildren.item(i); compareNodes(expectedChild, actualChild, false);
public ServiceCreationConfiguration<ClusteringService> parseServiceCreationConfiguration(final Element fragment, ClassLoader classLoader) { if ("cluster".equals(fragment.getLocalName())) { String clusterTierManager = null; Duration getTimeout = null, putTimeout = null, connectionTimeout = null; final NodeList childNodes = fragment.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { final Node item = childNodes.item(i); if (Node.ELEMENT_NODE == item.getNodeType()) { switch (item.getLocalName()) { case "connection": clusterTierManager = ((Element)item).getAttribute("cluster-tier-manager"); final NodeList serverNodes = item.getChildNodes(); for (int j = 0; j < serverNodes.getLength(); j++) { final Node serverNode = serverNodes.item(j); final String host = ((Element)serverNode).getAttributeNode("host").getValue(); final Attr port = ((Element)serverNode).getAttributeNode("port");
public static void injectAttrs( Node sourceNode, String classVal, String styleVal ) { log.debug("node type" + sourceNode.getNodeType()); switch (sourceNode.getNodeType() ) { for (int i=0; i<nodes.getLength(); i++) { log.debug("child " + i + "of DOCUMENT_NODE"); injectAttrs((Node)nodes.item(i), classVal, styleVal ); if (el.getLocalName()==null) {} else if (el.getLocalName().equals("div") || el.getLocalName().equals("p") || el.getLocalName().equals("ol") || el.getLocalName().equals("ul")) { if (el.getAttribute("class").trim().equals("") && el.getAttribute("style").trim().equals("") ) { for (int i=0; i<children.getLength(); i++) { injectAttrs((Node)children.item(i), classVal, styleVal );
String elName = el.getLocalName(); if (el.getNamespaceURI().equals(PackageProperties.NAMESPACE_DCTERMS)) if (!(elName.equals(KEYWORD_CREATED) || elName.equals(KEYWORD_MODIFIED))) throw new InvalidFormatException( if (el.getNamespaceURI().equals(PackageProperties.NAMESPACE_DCTERMS)) { int childElementCount = childElements.getLength(); for (int i = 0; i < childElementCount; i++) checkElementForOPCCompliance((Element)childElements.item(i));
/** * @param signatureElement * @return the node that is the signature * @throws TransformationException */ private static Node searchSignatureElement(Node signatureElement) throws TransformationException { boolean found = false; while (true) { if (signatureElement == null || signatureElement.getNodeType() == Node.DOCUMENT_NODE) { break; } Element el = (Element) signatureElement; if (el.getNamespaceURI().equals(Constants.SignatureSpecNS) && el.getLocalName().equals(Constants._TAG_SIGNATURE)) { found = true; break; } signatureElement = signatureElement.getParentNode(); } if (!found) { throw new TransformationException( "transform.envelopedSignatureTransformNotInSignatureElement"); } return signatureElement; }
Map<String, String> attributes = xmlEntity.getAttributes(); Element root = doc.getDocumentElement(); if (root.getLocalName().equals(type)) {
if ( childElement != null ) { if ( child.hasAttribute( WsdlUtils.ELEMENT_REF_ATTR ) ) { return wsdlTypes.getTypeQName( child.getAttribute( WsdlUtils.ELEMENT_REF_ATTR ) ); } else if ( child.hasAttribute( WsdlUtils.ELEMENT_TYPE_ATTR ) ) { return wsdlTypes.getTypeQName( child.getAttribute( WsdlUtils.ELEMENT_TYPE_ATTR ) ); return new QName( childElement.getNamespaceURI(), childElement.getLocalName() ); return new QName( "http://www.w3.org/2001/XMLSchema", "any" ); return new QName( "http://www.w3.org/2001/XMLSchema", "String" );
public XmlConfigurationWrapper documentToConfig(Document document, ClassLoader classLoader, Map<String, ClassLoader> cacheClassLoaders) throws JAXBException, ClassNotFoundException, InstantiationException, IllegalAccessException { substituteSystemProperties(document); Element root = document.getDocumentElement(); QName rootName = new QName(root.getNamespaceURI(), root.getLocalName()); if (!CORE_SCHEMA_ROOT_NAME.equals(rootName)) { throw new XmlConfigurationException("Expecting " + CORE_SCHEMA_ROOT_NAME + " element; found " + rootName);
setName( e.getAttribute( WsdlUtils.NAME_ATTR ), wsdlTypes ); _xmlType = wsdlTypes.getTypeQName( e.getAttribute( WsdlUtils.ELEMENT_TYPE_ATTR ) ); } else if ( e.hasAttribute( WsdlUtils.ELEMENT_REF_ATTR ) ) { _xmlType = wsdlTypes.getTypeQName( e.getAttribute( WsdlUtils.ELEMENT_REF_ATTR ) ); _name = new QName( "", _xmlType.getLocalPart() ); } else if ( e.hasAttribute( WsdlUtils.NAME_ATTR ) ) { setName( e.getAttribute( WsdlUtils.NAME_ATTR ), wsdlTypes ); if ( t != null && WsdlUtils.COMPLEX_TYPE_NAME.equals( t.getLocalName() ) ) { _itemXmlType = getArrayItemType( t, wsdlTypes ); _isArray = _itemXmlType != null;
Element el = doc.getDocumentElement(); if (!"http://java.sun.com/xml/ns/javaee".equals(el.getNamespaceURI()) || !"handler-chains".equals(el.getLocalName())) { "NOT_VALID_ROOT_ELEMENT", "http://java.sun.com/xml/ns/javaee" .equals(el.getNamespaceURI()), "handler-chains".equals(el.getLocalName()), xml, handlerFileURL)); if (node instanceof Element) { el = (Element)node; if (!"http://java.sun.com/xml/ns/javaee".equals(el.getNamespaceURI()) || !"handler-chain".equals(el.getLocalName())) {
private Element getWadlElement(Element wadlEl) { String href = wadlEl.getAttribute("href"); if (href.length() > 0 && href.startsWith("#")) { return resolveLocalReference(wadlEl.getOwnerDocument().getDocumentElement(), wadlEl.getLocalName(), href); } return wadlEl; }
/** * <p> * Returns a list of child elements with the given name. Returns an empty list if there are no such child elements. * </p> * * @param parent * parent element * @param localName * Local name of the child element * @return child elements */ protected static List<Element> getChildElementsByName( Element parent, String localName ) { List<Element> elements = new ArrayList<Element>(); NodeList children = parent.getChildNodes(); for ( int i = 0; i < children.getLength(); i++ ) { Node node = children.item( i ); if ( node.getNodeType() == Node.ELEMENT_NODE ) { Element element = (Element) node; if ( element.getLocalName().equals( localName ) ) { elements.add( element ); } } } return elements; } }
private String determineResourceName(Document theDocument) { Element root = null; NodeList list = theDocument.getChildNodes(); for (int i = 0; i < list.getLength(); i++) { if (list.item(i) instanceof Element) { root = (Element) list.item(i); break; } } root = theDocument.getDocumentElement(); return root.getLocalName(); }
trimEmptyTextNodes(actual); if (expected.getNodeType() != actual.getNodeType()) { throw new Exception("Different types of nodes: " + expected + " " + actual); Document expectedDoc = (Document) expected; Document actualDoc = (Document) actual; compareNodes(expectedDoc.getDocumentElement(), actualDoc.getDocumentElement(), false); } else if (expected instanceof Element) { Element expectedElement = (Element) expected; if (!expectedElement.getLocalName().equals(actualElement.getLocalName())) { throw new Exception("Element names do not match: " + expectedElement.getLocalName() + " " + actualElement.getLocalName()); String expectedNS = expectedElement.getNamespaceURI(); String actualNS = actualElement.getNamespaceURI(); if ((expectedNS == null && actualNS != null) || (expectedNS != null && !expectedNS.equals(actualNS))) { throw new Exception("Element namespaces names do not match: " + expectedNS + " " + actualNS); String elementName = "{" + expectedElement.getNamespaceURI() + "}" + actualElement.getLocalName(); for (int i = 0; i < expectedChildren.getLength(); i++) { Node expectedChild = expectedChildren.item(i); Node actualChild = actualChildren.item(i); compareNodes(expectedChild, actualChild, false);
public XmlNode updateXML(Object jaxbObject, XmlNode xmlNode) throws JAXBException { if(jaxbObject==null || xmlNode==null) throw new IllegalArgumentException(); // TODO // for now just marshal // TODO: object model independenc Element e = (Element)xmlNode; Node ns = e.getNextSibling(); Node p = e.getParentNode(); p.removeChild(e); // if the type object is passed, the following step is necessary to make // the marshalling successful. JaxBeanInfo bi = context.getBeanInfo(jaxbObject, true); if(!bi.isElement()) jaxbObject = new JAXBElement(new QName(e.getNamespaceURI(),e.getLocalName()),bi.jaxbType,jaxbObject); getMarshaller().marshal(jaxbObject,p); Node newNode = p.getLastChild(); p.removeChild(newNode); p.insertBefore(newNode,ns); return (XmlNode)newNode; }