org.jdom.Element.getNamespaceURI()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(144)

本文整理了Java中org.jdom.Element.getNamespaceURI()方法的一些代码示例,展示了Element.getNamespaceURI()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.getNamespaceURI()方法的具体详情如下:
包路径:org.jdom.Element
类名称:Element
方法名:getNamespaceURI

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: jaxen/jaxen

public String getElementNamespaceUri(Object obj)
{
  Element elem = (Element) obj;
  
  String uri = elem.getNamespaceURI();
  if ( uri != null && uri.length() == 0 ) 
    return null;
  else
    return uri;
}

代码示例来源:origin: org.freemarker/freemarker

@Override
String getNamespaceUri(Object node) {
  if (node instanceof Element) {
    return ((Element) node).getNamespaceURI();
  }
  if (node instanceof Attribute) {
    return ((Attribute) node).getNamespaceURI();
  }
  return null;
}

代码示例来源:origin: org.freemarker/freemarker

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());
*/                
    }
  }

代码示例来源:origin: org.freemarker/freemarker

@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);
    }
  }
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.freemarker

@Override
String getNamespaceUri(Object node) {
  if (node instanceof Element) {
    return ((Element) node).getNamespaceURI();
  }
  if (node instanceof Attribute) {
    return ((Attribute) node).getNamespaceURI();
  }
  return null;
}

代码示例来源:origin: org.freemarker/com.springsource.freemarker

String getNamespaceUri(Object node) {
  if(node instanceof Element) {
    return ((Element)node).getNamespaceURI();
  }
  if(node instanceof Attribute) {
    return ((Attribute)node).getNamespaceURI();
  }
  return null;
}

代码示例来源:origin: org.freemarker/freemarker-gae

@Override
String getNamespaceUri(Object node) {
  if (node instanceof Element) {
    return ((Element) node).getNamespaceURI();
  }
  if (node instanceof Attribute) {
    return ((Attribute) node).getNamespaceURI();
  }
  return null;
}

代码示例来源:origin: org.codehaus.xfire/xfire-core

protected MessagePartInfo getFaultPart(OperationInfo operation, Element exDetail)
{
  QName qname = new QName(exDetail.getNamespaceURI(), exDetail.getName());
  
  for (Iterator itr = operation.getFaults().iterator(); itr.hasNext();)
  {
    FaultInfo faultInfo = (FaultInfo) itr.next();
    
    MessagePartInfo part = faultInfo.getMessagePart(qname);
    
    if (part != null) return part;
  }
  
  return null;
}

代码示例来源:origin: org.codehaus.xfire/xfire-core

public QName getName()
{
  Element el = getCurrentElement();
  
  return new QName(el.getNamespaceURI(), el.getName(), el.getNamespacePrefix());
}

代码示例来源:origin: apache/cxf

public QName getName() {
  Element el = getCurrentElement();
  return new QName(el.getNamespaceURI(), el.getName(), el.getNamespacePrefix());
}

代码示例来源:origin: CeON/CERMINE

private void convertPages(Element source, DocumentMetadata metadata) throws JDOMException {
  XPath xpath = XPath.newInstance("./x:element/x:structure/x:current[@level='bwmeta1.level.hierarchy_Journal_Article']/@position");
  xpath.addNamespace("x", source.getNamespaceURI());
  Attribute pages = (Attribute)xpath.selectSingleNode(source);
  if (pages != null) {
    String fp = pages.getValue().replaceFirst("-.*", "");
    String lp = pages.getValue().replaceFirst(".*-", "");
    metadata.setPages(fp, lp);
  }
}

代码示例来源:origin: CeON/CERMINE

private void convertDoi(Element source, DocumentMetadata metadata) throws JDOMException {
  XPath xpath = XPath.newInstance(".//x:idno[@type='DOI']");
  xpath.addNamespace("x", source.getNamespaceURI());
  Element doi = (Element)xpath.selectSingleNode(source);
  if (doi != null) {
    metadata.addId(IDType.DOI, XMLTools.getTextContent(doi));
  }
}

代码示例来源:origin: CeON/CERMINE

private void convertVolume(Element source, DocumentMetadata metadata) throws JDOMException {
  XPath xpath = XPath.newInstance("./x:element/x:structure/x:ancestor[@level='bwmeta1.level.hierarchy_Journal_Volume']/x:name[@type='canonical']");
  xpath.addNamespace("x", source.getNamespaceURI());
  Element volume = (Element)xpath.selectSingleNode(source);
  if (volume != null) {
    metadata.setVolume(XMLTools.getTextContent(volume));
  }
}

代码示例来源:origin: CeON/CERMINE

private void convertYear(Element source, DocumentMetadata metadata) throws JDOMException {
  XPath xpath = XPath.newInstance("./x:element/x:structure/x:ancestor[@level='bwmeta1.level.hierarchy_Journal_Year']/x:name[@type='canonical']");
  xpath.addNamespace("x", source.getNamespaceURI());
  Element year = (Element)xpath.selectSingleNode(source);
  if (year != null) {
    metadata.setDate(DateType.PUBLISHED, null, null, XMLTools.getTextContent(year));
  }
}

代码示例来源:origin: CeON/CERMINE

private void convertAbstract(Element source, DocumentMetadata metadata) throws JDOMException {
  XPath xpath = XPath.newInstance(".//x:abstract");
  xpath.addNamespace("x", source.getNamespaceURI());
  Element abstrakt = (Element)xpath.selectSingleNode(source);
  if (abstrakt != null) {
    metadata.setAbstrakt(XMLTools.getTextContent(abstrakt));
  }
}

代码示例来源:origin: CeON/CERMINE

private void convertTitle(Element source, DocumentMetadata metadata) throws JDOMException {
  XPath xpath = XPath.newInstance("./x:element/x:name[not(@type)]");
  xpath.addNamespace("x", source.getNamespaceURI());
  Element title = (Element)xpath.selectSingleNode(source);
  if (title != null) {
    metadata.setTitle(XMLTools.getTextContent(title));
  }
}

代码示例来源:origin: CeON/CERMINE

private void convertVolume(Element source, DocumentMetadata metadata) throws JDOMException {
  XPath xpath = XPath.newInstance(".//x:monogr/x:imprint/x:biblScope[@unit='volume']");
  xpath.addNamespace("x", source.getNamespaceURI());
  Element volume = (Element)xpath.selectSingleNode(source);
  if (volume != null) {
    metadata.setVolume(XMLTools.getTextContent(volume));
  }
}

代码示例来源:origin: CeON/CERMINE

private void convertIssue(Element source, DocumentMetadata metadata) throws JDOMException {
  XPath xpath = XPath.newInstance(".//x:monogr/x:imprint/x:biblScope[@unit='issue']");
  xpath.addNamespace("x", source.getNamespaceURI());
  Element issue = (Element)xpath.selectSingleNode(source);
  if (issue != null) {
    metadata.setIssue(XMLTools.getTextContent(issue));
  }
}

代码示例来源:origin: CeON/CERMINE

private void convertTitle(Element source, DocumentMetadata metadata) throws JDOMException {
  XPath xpath = XPath.newInstance(".//x:titleStmt/x:title");
  xpath.addNamespace("x", source.getNamespaceURI());
  Element title = (Element)xpath.selectSingleNode(source);
  if (title != null) {
    metadata.setTitle(XMLTools.getTextContent(title));
  }
}

代码示例来源:origin: CeON/CERMINE

private void convertJournal(Element source, DocumentMetadata metadata) throws JDOMException {
  XPath xpath = XPath.newInstance("./x:element/x:structure/x:ancestor[@level='bwmeta1.level.hierarchy_Journal_Journal']/x:name[@type='canonical']");
  xpath.addNamespace("x", source.getNamespaceURI());
  Element journal = (Element)xpath.selectSingleNode(source);
  if (journal != null) {
    metadata.setJournal(XMLTools.getTextContent(journal));
  }
}

相关文章

微信公众号

最新文章

更多