Element node = (Element) contextNode; if (namespaceURI == null) { return node.getChildren(localName).iterator(); return node.getChildren(localName, Namespace.getNamespace(namespacePrefix, namespaceURI)).iterator(); Element el = node.getRootElement(); if (el.getName().equals(localName) == false) { return JaxenConstants.EMPTY_ITERATOR; if (!Namespace.getNamespace(namespacePrefix, namespaceURI).equals(el.getNamespace())) { return JaxenConstants.EMPTY_ITERATOR;
public List operate(Object node, String localName, Namespace namespace) { if (node instanceof Element) { return((Element) node).getChildren(localName, namespace); } else if (node instanceof Document) { Element root = ((Document) node).getRootElement(); if (root != null && root.getName().equals(localName) && root.getNamespaceURI().equals(namespace.getURI())) { return Collections.singletonList(root); } else return Collections.EMPTY_LIST; } // With 2.1 semantics it makes more sense to just return a null and let the core // throw an InvalidReferenceException and the template writer can use ?exists etcetera. (JR) return null; /* else throw new TemplateModelException("_namedChildren can not be applied on " + node.getClass()); */ } }
public Element visit(final ASTNullLiteral node, final Element data) throws XPathExpressionException { final Element res = new Element("value"); res.setAttribute("type", "xsd:string"); res.addNamespaceDeclaration(Namespace.getNamespace("xsd", Constants.SCHEMA_NAMESPACE)); this.log.finest(this.indentString() + node); ++this.indent; final Document doc = new Document(res); this.log.finest(this.indentString() + node); --this.indent; return doc.getRootElement(); }
public static Element createSOAPFault(final Element content) { Element soapfault = null; //TODO: create soap1.2 fault // create soap1.1 fault soapfault = new Element("Fault", Namespace.getNamespace("soap", "http://schemas.xmlsoap.org/soap/envelope/")); final Document doc = new Document(soapfault); final Element faultcode = new Element("faultcode"); faultcode.setText("soap:Server"); soapfault.addContent(faultcode); final Element detail = new Element("detail"); if(content != null) { detail.addContent((Element)content.clone()); } soapfault.addContent(detail); return doc.getRootElement(); }
@Override void getChildren(Object node, String localName, String namespaceUri, List result) { if (node instanceof Element) { Element e = (Element) node; if (localName == null) { result.addAll(e.getChildren()); } else { result.addAll(e.getChildren(localName, Namespace.getNamespace("", namespaceUri))); } } else if (node instanceof Document) { Element root = ((Document) node).getRootElement(); if (localName == null || (equal(root.getName(), localName) && equal(root.getNamespaceURI(), namespaceUri))) { result.add(root); } } }
public boolean isMyType(Document document) { Element rssRoot = document.getRootElement(); Namespace defaultNS = rssRoot.getNamespace(); return (defaultNS!=null) && defaultNS.equals(getAtomNamespace()); }
private void addImports(Document doc) { Element process = doc.getRootElement(); Element importElem = new Element("import", CoverageConstants.BPEL_NS); importElem.setAttribute("namespace", CoverageConstants.COVERAGETOOL_NAMESPACE.getURI()); importElem.setAttribute("location", CoverageConstants.COVERAGE_SERVICE_WSDL); importElem.setAttribute("importType", CoverageConstants.WSDL_IMPORT_TYPE); process.addContent(importElem); }
private void addSupportedTopicAttr(final List<org.jdom.Element> children, final List<String> topics) { for(final org.jdom.Element child: children) { if(child.getName().equals(WstopConstants.TOPIC_QNAME.getLocalPart())&&child.getNamespaceURI().equals(WstopConstants.TOPIC_QNAME.getNamespaceURI())) { if(topics.contains(child.getAttribute("name").getValue())) { child.setAttribute(WsnExtensionConstants.SUPPORTED_QNAME_ATTR.getLocalPart(), "true", Namespace.getNamespace(WsnExtensionConstants.SUPPORTED_QNAME_ATTR.getPrefix(), WsnExtensionConstants.SUPPORTED_QNAME_ATTR.getNamespaceURI())); } if(child.getChildren() != null && child.getChildren().size() > 0) { this.addSupportedTopicAttr(child.getChildren(), topics); } } } }
@SuppressWarnings("unchecked") public static Element findElementWithAttributeValue(Element element, String name, String attrName, String attrValue, Namespace... supportedNamespaces) { for (Namespace ns : supportedNamespaces) { if (element.getName().equals(name) && element.getNamespace().equals(ns)) { Attribute attribute = element.getAttribute(attrName); if (attribute != null && attrValue.equals(attribute.getValue())) { return element; } } for (Element ch : (List<Element>) element.getChildren()) { Element result = findElementWithAttributeValue(ch, name, attrName, attrValue, supportedNamespaces); if (result != null) { return result; } } } return null; }
private void createDocumentation(List messageParts){ for(Iterator itr = messageParts.iterator();itr.hasNext();){ MessagePartInfo param = (MessagePartInfo) itr.next(); if( param.getDocumentation() != null){ Element e = (Element) typeMap.get(param.getName().getNamespaceURI()); List children = e.getChildren("element",Namespace.getNamespace(SoapConstants.XSD)); for( Iterator elemItr = children.iterator(); elemItr.hasNext();){ Element elem = (Element) elemItr .next(); if(elem.getAttribute("name").getValue().equals(param.getName().getLocalPart())){ elem.addContent(createDocElement(param.getDocumentation())); break; } } } } } private Message createInputMessage(OperationInfo op)
/** * Indicates if a JDom document is an RSS instance that can be parsed with the parser. * <p/> * It checks for RDF ("http://www.w3.org/1999/02/22-rdf-syntax-ns#") and * RSS ("http://purl.org/rss/1.0/") namespaces being defined in the root element. * * @param document document to check if it can be parsed with this parser implementation. * @return <b>true</b> if the document is RSS1., <b>false</b> otherwise. */ public boolean isMyType(Document document) { boolean ok = false; Element rssRoot = document.getRootElement(); Namespace defaultNS = rssRoot.getNamespace(); List additionalNSs = rssRoot.getAdditionalNamespaces(); ok = (defaultNS != null) && defaultNS.equals(getRSSNamespace()); return ok; }
@Override public String writeUser(UserData userData) throws ExportException { Namespace ns = Namespace.getNamespace(USERCATALOG_NAMESPACE_PREFIX, USERCATALOG_NAMESPACE); Namespace nsXsi = Namespace.getNamespace(XSI_NAMESPACE_PREFIX, XSI_NAMESPACE); Document doc = new Document(dumpUser(userData, ns)); doc.getRootElement().setNamespace(ns); doc.getRootElement().addNamespaceDeclaration(nsXsi); doc.getRootElement().setAttribute( new Attribute("schemaLocation", USERCATALOG_NAMESPACE + " " + USER_SCHEMA_LOCATION, nsXsi)); XMLOutputter xmlOutputter = getOutputter(); String xml = xmlOutputter.outputString(doc); SAXBuilder saxBuilder = getBuilder(USER_SCHEMA_RESOURCE); try { saxBuilder.build(IOUtils.toInputStream(xml)); return xml; } catch (Exception e) { throw new ExportException("Error during validating output.", e); } }
private boolean hasElementsFrom(Element root, Namespace namespace) { boolean hasElements = false; // boolean hasElements = namespace.equals(root.getNamespace()); if (!hasElements) { List children = root.getChildren(); for (int i=0;!hasElements && i < children.size();i++) { Element child = (Element) children.get(i); hasElements = namespace.equals(child.getNamespace()); } } return hasElements; } }
public List operate(Object node) { if (node instanceof Element) { Element element = (Element) node; return Collections.singletonList(element.getNamespace().getURI() + element.getName()); } else if (node instanceof Attribute) { Attribute attribute = (Attribute) node; return Collections.singletonList(attribute.getNamespace().getURI() + attribute.getName()); } // With 2.1 semantics it makes more sense to just return a null and let the core // throw an InvalidReferenceException and the template writer can use ?exists etcetera. (JR) return null; // throw new TemplateModelException("_cname can not be applied on " + node.getClass()); } }
private static void checkNamespace(final String systemId, final Document document) { final Namespace actualNamespace = document.getRootElement().getNamespace(); if (!NS.equals(actualNamespace)) { throw new ConfigException(namespace(systemId, NS.getURI(), actualNamespace.getURI())); } }
public void writeAttribute(String namespace, String local, String value) throws XMLStreamException { currentNode.setAttribute(new Attribute(local, value, Namespace.getNamespace(namespace))); }
private static void applyDim(Context context, List<Element> dimList, Item item, boolean createMissingMetadataFields) throws CrosswalkException, SQLException, AuthorizeException { for (Element elt : dimList) { if ("field".equals(elt.getName()) && DIM_NS.equals(elt.getNamespace())) { applyDimField(context, elt, item, createMissingMetadataFields); } else if ("dim".equals(elt.getName()) && DIM_NS.equals(elt.getNamespace())) { // if it's a <dim> container, apply its guts applyDim(context, elt.getChildren(), item, createMissingMetadataFields); } else { log.error("Got unexpected element in DIM list: " + elt.toString()); throw new MetadataValidationException("Got unexpected element in DIM list: " + elt.toString()); } } }
public Element getImport(Element schema, String ns) { List children = schema.getChildren("import", Namespace.getNamespace(SoapConstants.XSD)); for (int i = 0; i < children.size(); i++) { Element importEl = (Element) children.get(i); String value = importEl.getAttributeValue("namespace"); if (value != null && value.equals(ns)) return importEl; } return null; }
public static List<Element> getTargets(Element child) { Namespace ns = getProcessNamespace(); List<Element> targets = new ArrayList<Element>(); if (ns.equals(NAMESPACE_BPEL_1_1)) { targets.addAll(child.getChildren(TARGET_ELEMENT, ns)); } else if (ns.equals(NAMESPACE_BPEL_2_0)) { Element target = child.getChild(TARGETS_ELEMENT, ns); if (target != null) { targets.add(target); } } return targets; }