@Override public final String getElementNamespaceUri(Object element) { return ((Element)element).getNamespaceURI(); }
/** * <p> * This returns a <code>String</code> representation of the * <code>Element</code>, suitable for debugging. If the XML * representation of the <code>Element</code> is desired, * {@link org.jdom2.output.XMLOutputter#outputString(Element)} * should be used. * </p> * * @return <code>String</code> - information about the * <code>Element</code> */ @Override public String toString() { final StringBuilder stringForm = new StringBuilder(64) .append("[Element: <") .append(getQualifiedName()); final String nsuri = getNamespaceURI(); if (!"".equals(nsuri)) { stringForm .append(" [Namespace: ") .append(nsuri) .append("]"); } stringForm.append("/>]"); return stringForm.toString(); }
/** * @return the namespace URI. * @see org.jdom2.Element#getNamespaceURI() */ public String getNamespaceURI() { return element.getNamespaceURI(); }
element.getNamespaceURI(), element.getQualifiedName());
String xps = "*[local-name() = '" + emt.getName() + "' and namespace-uri() = '" + emt.getNamespaceURI() + "']"; return getPositionPath(content, sibs, xps, buffer);
ch.startElement(element.getNamespaceURI(), element.getName(), element.getQualifiedName(), atts); out.getContentHandler().endElement(element.getNamespaceURI(), element.getName(), element.getQualifiedName());
element.getNamespaceURI(), element.getName(), new NSIterator(nstack.addedReverse().iterator(), eventfactory)));
public static boolean supportsClassification(org.jdom2.Element modsElement) { return modsElement.getNamespaceURI().equals(NS_MODS_URI) && SUPPORTED.contains(modsElement.getName()); }
private Set<QName> getProps(Document doc) { Element elProp = doc.getRootElement().getChild("prop", NS_DAV); if (elProp == null) { throw new RuntimeException("No prop element"); } Set<QName> set = new HashSet<QName>(); for (Object o : elProp.getChildren()) { if (o instanceof Element) { Element el = (Element) o; String local = el.getName(); String ns = el.getNamespaceURI(); set.add(new QName(ns, local, el.getNamespacePrefix())); } } return set; } }
private Set<QName> getProps(Document doc) { Element elProp = doc.getRootElement().getChild("prop", NS_DAV); if (elProp == null) { throw new RuntimeException("No prop element"); } Set<QName> set = new HashSet<QName>(); for (Object o : elProp.getChildren()) { if (o instanceof Element) { Element el = (Element) o; String local = el.getName(); String ns = el.getNamespaceURI(); set.add(new QName(ns, local, el.getNamespacePrefix())); } } return set; } }
private Set<QName> getProps(Document doc) { Element elProp = doc.getRootElement().getChild("prop", NS_DAV); if (elProp == null) { throw new RuntimeException("No prop element"); } Set<QName> set = new HashSet<QName>(); for (Object o : elProp.getChildren()) { if (o instanceof Element) { Element el = (Element) o; String local = el.getName(); String ns = el.getNamespaceURI(); set.add(new QName(ns, local, el.getNamespacePrefix())); } } return set; } }
public static Set<QName> getProps(Document doc, Namespace propNs) { Element elProp = doc.getRootElement().getChild("prop", propNs); if (elProp == null) { throw new RuntimeException("No prop element"); } Set<QName> set = new HashSet<QName>(); for (Object o : elProp.getChildren()) { if (o instanceof Element) { Element el = (Element) o; String local = el.getName(); String ns = el.getNamespaceURI(); set.add(new QName(ns, local, el.getNamespacePrefix())); } } return set; } }
private Set<QName> getProps( Document doc ) { Element elProp = doc.getRootElement().getChild( "prop", this.NS_DAV ); if ( elProp == null ) { throw new RuntimeException( "No prop element" ); } Set<QName> set = new HashSet<QName>(); for ( Object o : elProp.getChildren() ) { if ( o instanceof Element ) { Element el = (Element)o; String local = el.getName(); String ns = el.getNamespaceURI(); set.add( new QName( ns, local, el.getNamespacePrefix() ) ); } } return set; } }
private static void _findAll(Element root, String name, Namespace ns, List<Element> list) { for (Object child : root.getChildren()) { if (child instanceof Element) { Element elChild = (Element) child; if (elChild.getName().equals(name)) { if (ns == null || ns.getURI().equals(elChild.getNamespaceURI())) { list.add(elChild); } } } } for (Object child : root.getChildren()) { if (child instanceof Element) { Element elChild = (Element) child; _findAll(elChild, name, ns, list); } } }
protected List<Element> extractForeignMarkup(final Element e, final Extendable ext, final Namespace namespace) { final ArrayList<Element> foreignElements = new ArrayList<Element>(); for (final Element element : e.getChildren()) { if (!namespace.equals(element.getNamespace()) && ext.getModule(element.getNamespaceURI()) == null) { // if element not in the RSS namespace and elem was not handled by a module save it // as foreign markup but we can't detach it while we're iterating foreignElements.add(element.clone()); } } // now we can detach the foreign markup elements for (final Element foreignElement : foreignElements) { foreignElement.detach(); } return foreignElements; }
protected List<Element> extractForeignMarkup(final Element e, final Extendable ext, final Namespace namespace) { final ArrayList<Element> foreignElements = new ArrayList<Element>(); for (final Element element : e.getChildren()) { if (!namespace.equals(element.getNamespace()) && ext.getModule(element.getNamespaceURI()) == null) { // if element not in the RSS namespace and elem was not handled by a module save it // as foreign markup but we can't detach it while we're iterating foreignElements.add(element.clone()); } } // now we can detach the foreign markup elements for (final Element foreignElement : foreignElements) { foreignElement.detach(); } return foreignElements; }
protected List extractForeignMarkup(Element e, Extendable ext, Namespace basens) { ArrayList foreignMarkup = new ArrayList(); for (Element elem : e.getChildren()) { if ( // if elemet not in the RSS namespace !basens.equals(elem.getNamespace()) // and elem was not handled by a module && null == ext.getModule(elem.getNamespaceURI())) { // save it as foreign markup, // but we can't detach it while we're iterating foreignMarkup.add(elem.clone()); } } // Now we can detach the foreign markup elements for (Object aForeignMarkup : foreignMarkup) { Element elem = (Element) aForeignMarkup; elem.detach(); } return foreignMarkup; }
private boolean isGetCoverageWcsDoc(String url) throws JDOMException, IOException { byte[] result = TestOnLocalServer.getContent(url+baloney+"&request=GetCapabilities", 200, ContentType.xml); Reader in = new StringReader( new String(result, CDM.utf8Charset)); SAXBuilder sb = new SAXBuilder(); Document doc = sb.build(in); boolean isName = doc.getRootElement().getName().equals("WCS_Capabilities"); boolean isNamespace = doc.getRootElement().getNamespaceURI().equals(NS_WCS.getURI()); return (isName && isNamespace); }
@Override public void perform(Element originalElement, Element patchElement, Element outputParentElement) throws AbstractXmlMergeException { logger.fine("Merging: " + originalElement + " (original) and " + patchElement + "(patch)"); Mapper mapper = (Mapper) m_mapperFactory.getOperation(originalElement, patchElement); if (originalElement == null) { outputParentElement.addContent(mapper.map(patchElement)); } else if (patchElement == null) { outputParentElement.addContent((Content) originalElement.clone()); } else { Element workingElement = new Element(originalElement.getName(), originalElement .getNamespacePrefix(), originalElement.getNamespaceURI()); addAttributes(workingElement, originalElement); logger.fine("Adding " + workingElement); outputParentElement.addContent(workingElement); doIt(workingElement, originalElement, patchElement); } }
@Test public void checkWCSDates() throws JDOMException, IOException { String endpoint = TestOnLocalServer.withHttpPath("/wcs/cdmUnitTest/ncss/climatology/PF5_SST_Climatology_Monthly_1985_2001.nc?service=WCS&version=1.0.0&request=DescribeCoverage&coverage=sst"); byte[] result = TestOnLocalServer.getContent(endpoint, 200, ContentType.xml); Reader in = new StringReader( new String(result, CDM.utf8Charset)); SAXBuilder sb = new SAXBuilder(); Document doc = sb.build(in); Namespace wcs = Namespace.getNamespace("wcs", doc.getRootElement().getNamespaceURI()); Namespace gml = Namespace.getNamespace("gml", "http://www.opengis.net/gml"); XPathExpression<Element> xpath = XPathFactory.instance().compile("//wcs:temporalDomain/gml:timePosition", Filters.element(), null, wcs, gml); List<Element> timePositionNodes = xpath.evaluate(doc); List<String> timePositionDateTime = new ArrayList<>(); for (Element e : timePositionNodes) { System.out.printf("Date= %s%n", e.getText()); CalendarDate cd = CalendarDate.parseISOformat(null, e.getText()); timePositionDateTime.add(cd.toString()); } assertEquals(expectedDatesAsDateTime, timePositionDateTime); }