org.jdom.Namespace类的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(11.2k)|赞(0)|评价(0)|浏览(188)

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

Namespace介绍

[英]An XML namespace representation, as well as a factory for creating XML namespace objects. Namespaces are not Serializable, however objects that use namespaces have special logic to handle serialization manually. These classes call the getNamespace() method on deserialization to ensure there is one unique Namespace object for any unique prefix/uri pair.
[中]XML命名空间表示,以及用于创建XML命名空间对象的工厂。名称空间不可序列化,但是使用名称空间的对象具有手动处理序列化的特殊逻辑。这些类在反序列化时调用getNamespace()方法,以确保任何唯一前缀/uri对都有一个唯一的命名空间对象。

代码示例

代码示例来源:origin: jaxen/jaxen

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;

代码示例来源: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: jaxen/jaxen

public String toString()
  {
    return ( "[xmlns:" + jdomNamespace.getPrefix() + "=\"" +
         jdomNamespace.getURI() + "\", element=" +
         jdomElement.getName() + "]" );
  }
}

代码示例来源:origin: com.ebmwebsourcing.easybpel/easybpel.xpath.exp.impl

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

代码示例来源:origin: com.ebmwebsourcing.easybpel/easybpel.model.bpel.impl

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

代码示例来源: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: rome/rome

public boolean isMyType(Document document) {
  Element rssRoot = document.getRootElement();
  Namespace defaultNS = rssRoot.getNamespace();
  return (defaultNS!=null) && defaultNS.equals(getAtomNamespace());
}

代码示例来源:origin: net.bpelunit/framework

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

代码示例来源:origin: com.ebmwebsourcing.wsstar/ws-notification-service

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

代码示例来源:origin: wildfly-extras/wildfly-camel

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

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

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)

代码示例来源:origin: rome/modules

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

代码示例来源:origin: pl.edu.icm.yadda/yadda-user

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

代码示例来源:origin: rome/rome

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

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

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

代码示例来源:origin: de.smartics.properties/smartics-properties-config

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

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

public void writeAttribute(String namespace, String local, String value)
  throws XMLStreamException
{
  currentNode.setAttribute(new Attribute(local, value, Namespace.getNamespace(namespace)));
}

代码示例来源:origin: DSpace/DSpace

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

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

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

代码示例来源:origin: net.bpelunit/framework

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

相关文章