本文整理了Java中org.jdom2.Element.getNamespaceURI()
方法的一些代码示例,展示了Element.getNamespaceURI()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.getNamespaceURI()
方法的具体详情如下:
包路径:org.jdom2.Element
类名称:Element
方法名:getNamespaceURI
[英]Returns the namespace URI mapped to this element's prefix (or the in-scope default namespace URI if no prefix). If no mapping is found, an empty string is returned.
[中]返回映射到此元素前缀的命名空间URI(如果没有前缀,则返回范围内的默认命名空间URI)。如果未找到映射,则返回空字符串。
代码示例来源:origin: org.jdom/jdom
@Override
public final String getElementNamespaceUri(Object element) {
return ((Element)element).getNamespaceURI();
}
代码示例来源:origin: org.jdom/jdom
/**
* <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();
}
代码示例来源:origin: org.codehaus.plexus/plexus-component-metadata
/**
* @return the namespace URI.
* @see org.jdom2.Element#getNamespaceURI()
*/
public String getNamespaceURI()
{
return element.getNamespaceURI();
}
代码示例来源:origin: org.jdom/jdom
element.getNamespaceURI(), element.getQualifiedName());
代码示例来源:origin: org.jdom/jdom
String xps = "*[local-name() = '" + emt.getName() +
"' and namespace-uri() = '" +
emt.getNamespaceURI() + "']";
return getPositionPath(content, sibs, xps, buffer);
代码示例来源:origin: org.jdom/jdom
ch.startElement(element.getNamespaceURI(), element.getName(),
element.getQualifiedName(), atts);
out.getContentHandler().endElement(element.getNamespaceURI(),
element.getName(), element.getQualifiedName());
代码示例来源:origin: org.jdom/jdom
element.getNamespaceURI(), element.getName(),
new NSIterator(nstack.addedReverse().iterator(), eventfactory)));
代码示例来源:origin: org.mycore/mycore-mods
public static boolean supportsClassification(org.jdom2.Element modsElement) {
return modsElement.getNamespaceURI().equals(NS_MODS_URI) && SUPPORTED.contains(modsElement.getName());
}
代码示例来源:origin: miltonio/milton2
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;
}
}
代码示例来源:origin: miltonio/milton2
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;
}
}
代码示例来源:origin: miltonio/milton2
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;
}
}
代码示例来源:origin: miltonio/milton2
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;
}
}
代码示例来源:origin: miltonio/milton2
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;
}
}
代码示例来源:origin: miltonio/milton2
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);
}
}
}
代码示例来源:origin: rometools/rome
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;
}
代码示例来源:origin: com.rometools/rome
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;
}
代码示例来源:origin: apache/marmotta
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;
}
代码示例来源:origin: Unidata/thredds
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);
}
代码示例来源:origin: org.codehaus.izpack/izpack-util
@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);
}
}
代码示例来源:origin: Unidata/thredds
@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);
}
内容来源于网络,如有侵权,请联系作者删除!