javax.xml.stream.events.Namespace.getNamespaceURI()方法的使用及代码示例

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

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

Namespace.getNamespaceURI介绍

[英]Gets the uri bound to the prefix of this namespace
[中]获取绑定到此命名空间前缀的uri

代码示例

代码示例来源:origin: plutext/docx4j

/**
 * Adds a namespace declaration attribute to the given element.
 */
public static void addNamespaceDeclaration(Element element, Namespace namespace) {
  addNamespaceDeclaration(element, namespace.getPrefix(), namespace.getNamespaceURI());
}

代码示例来源:origin: org.apache.poi/poi-ooxml

/**
   * Adds a namespace declaration attribute to the given element.
   */
  public static void addNamespaceDeclaration(Element element, Namespace namespace) {
    addNamespaceDeclaration(element, namespace.getPrefix(), namespace.getNamespaceURI());
  }
}

代码示例来源:origin: spring-projects/spring-framework

for (Iterator i = event.getNamespaces(); i.hasNext();) {
  Namespace namespace = (Namespace) i.next();
  String prefix = namespace.getPrefix();
  String namespaceUri = namespace.getNamespaceURI();
  String qName;
  if (StringUtils.hasLength(prefix)) {

代码示例来源:origin: spring-projects/spring-framework

private void handleStartElement(StartElement startElement) throws SAXException {
  if (getContentHandler() != null) {
    QName qName = startElement.getName();
    if (hasNamespacesFeature()) {
      for (Iterator i = startElement.getNamespaces(); i.hasNext();) {
        Namespace namespace = (Namespace) i.next();
        startPrefixMapping(namespace.getPrefix(), namespace.getNamespaceURI());
      }
      for (Iterator i = startElement.getAttributes(); i.hasNext();){
        Attribute attribute = (Attribute) i.next();
        QName attributeName = attribute.getName();
        startPrefixMapping(attributeName.getPrefix(), attributeName.getNamespaceURI());
      }
      getContentHandler().startElement(qName.getNamespaceURI(), qName.getLocalPart(), toQualifiedName(qName),
          getAttributes(startElement));
    }
    else {
      getContentHandler().startElement("", "", toQualifiedName(qName), getAttributes(startElement));
    }
  }
}

代码示例来源:origin: hibernate/hibernate-orm

private Namespace mapNamespace(Namespace originalNamespace) {
  if ( NAMESPACE_URIS_TO_MAP.contains( originalNamespace.getNamespaceURI() ) ) {
    // this is a namespace "to map" so map it
    return xmlEventFactory.createNamespace( originalNamespace.getPrefix(), MappingXsdSupport.INSTANCE.latestJpaDescriptor().getNamespaceUri() );
  }
  return originalNamespace;
}

代码示例来源:origin: org.springframework/spring-core

for (Iterator i = event.getNamespaces(); i.hasNext();) {
  Namespace namespace = (Namespace) i.next();
  String prefix = namespace.getPrefix();
  String namespaceUri = namespace.getNamespaceURI();
  String qName;
  if (StringUtils.hasLength(prefix)) {

代码示例来源:origin: org.springframework/spring-core

private void handleStartElement(StartElement startElement) throws SAXException {
  if (getContentHandler() != null) {
    QName qName = startElement.getName();
    if (hasNamespacesFeature()) {
      for (Iterator i = startElement.getNamespaces(); i.hasNext();) {
        Namespace namespace = (Namespace) i.next();
        startPrefixMapping(namespace.getPrefix(), namespace.getNamespaceURI());
      }
      for (Iterator i = startElement.getAttributes(); i.hasNext();){
        Attribute attribute = (Attribute) i.next();
        QName attributeName = attribute.getName();
        startPrefixMapping(attributeName.getPrefix(), attributeName.getNamespaceURI());
      }
      getContentHandler().startElement(qName.getNamespaceURI(), qName.getLocalPart(), toQualifiedName(qName),
          getAttributes(startElement));
    }
    else {
      getContentHandler().startElement("", "", toQualifiedName(qName), getAttributes(startElement));
    }
  }
}

代码示例来源:origin: pentaho/pentaho-kettle

@SuppressWarnings( "unchecked" )
private Object[] parseNamespaces( Object[] outputRowData, XMLEvent e ) throws KettleValueException,
 KettleStepException {
 Iterator<Namespace> iter = e.asStartElement().getNamespaces();
 if ( iter.hasNext() ) {
  Object[] outputRowDataNamespace = data.outputRowMeta.cloneRow( outputRowData );
  putRowOut( outputRowDataNamespace ); // first put the element name info out
  // change data_type to ATTRIBUTE
  if ( data.pos_xml_data_type_numeric != -1 ) {
   outputRowData[data.pos_xml_data_type_numeric] = new Long( XMLStreamConstants.NAMESPACE );
  }
  if ( data.pos_xml_data_type_description != -1 ) {
   outputRowData[data.pos_xml_data_type_description] = eventDescription[XMLStreamConstants.NAMESPACE];
  }
 }
 while ( iter.hasNext() ) {
  Object[] outputRowDataNamespace = data.outputRowMeta.cloneRow( outputRowData );
  Namespace n = iter.next();
  outputRowDataNamespace[data.pos_xml_data_name] = n.getPrefix();
  outputRowDataNamespace[data.pos_xml_data_value] = n.getNamespaceURI();
  if ( iter.hasNext() ) {
   // send out the Namespace row
   putRowOut( outputRowDataNamespace );
  } else {
   // last row: this will be sent out by the outer loop
   outputRowData = outputRowDataNamespace;
  }
 }
 return outputRowData;
}

代码示例来源:origin: hibernate/hibernate-orm

while ( originalNamespaces.hasNext() ) {
  Namespace namespace = originalNamespaces.next();
  if ( NAMESPACE_URIS_TO_MAP.contains( namespace.getNamespaceURI() ) ) {
    namespace = xmlEventFactory.createNamespace( namespace.getPrefix(), MappingXsdSupport.INSTANCE.hbmXsd().getNamespaceUri() );

代码示例来源:origin: com.sun.xml.bind/jaxb-impl

private void handleStartElement(StartElement event) throws SAXException {
  // start namespace bindings
  for (Iterator i = event.getNamespaces(); i.hasNext();) {
    Namespace ns = (Namespace)i.next();
    visitor.startPrefixMapping(
      fixNull(ns.getPrefix()),
      fixNull(ns.getNamespaceURI()));
  }
  // fire startElement
  QName qName = event.getName();
  tagName.uri = fixNull(qName.getNamespaceURI());
  String localName = qName.getLocalPart();
  tagName.uri = fixNull(qName.getNamespaceURI());
  tagName.local = localName;
  tagName.atts = getAttributes(event);
  visitor.startElement(tagName);
  seenText = false;
}

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

/**
 * Constructs a new DOM4J Namespace from the provided StAX Namespace event.
 * 
 * @param ns
 *            The Namespace event from which to construct the new DOM4J
 *            Namespace.
 * 
 * @return The Namespace constructed from the provided Namespace event.
 */
public org.dom4j.Namespace createNamespace(Namespace ns) {
  return factory.createNamespace(ns.getPrefix(), ns.getNamespaceURI());
}

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

/**
 * Method called by the matching start element class to
 * output all namespace declarations active in current namespace
 * scope, if any.
 */
public void outputNamespaceDeclarations(XMLStreamWriter w) throws XMLStreamException
{
  for (int i = 0, len = mNamespaces.size(); i < len; ++i) {
    Namespace ns = (Namespace) mNamespaces.get(i);
    if (ns.isDefaultNamespaceDeclaration()) {
      w.writeDefaultNamespace(ns.getNamespaceURI());
    } else {
      w.writeNamespace(ns.getPrefix(), ns.getNamespaceURI());
    }
  }
}

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

public void outputNamespaceDeclarations(Writer w) throws IOException
{
  for (int i = 0, len = mNamespaces.size(); i < len; ++i) {
    Namespace ns = (Namespace) mNamespaces.get(i);
    w.write(' ');
    w.write(XMLConstants.XMLNS_ATTRIBUTE);
    if (!ns.isDefaultNamespaceDeclaration()) {
      w.write(':');
      w.write(ns.getPrefix());
    }
    w.write("=\"");
    w.write(ns.getNamespaceURI());
    w.write('"');
  }
}

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

public Iterator doGetPrefixes(String nsURI)
{
  // Note: base class checks for 'known' problems and prefixes:
  ArrayList l = null;
  for (int i = 0, len = mNamespaces.size(); i < len; ++i) {
    Namespace ns = (Namespace) mNamespaces.get(i);
    String uri = ns.getNamespaceURI();
    if (uri == null) {
      uri = "";
    }
    if (uri.equals(nsURI)) {
      if (l == null) {
        l = new ArrayList();
      }
      String prefix = ns.getPrefix();
      l.add((prefix == null) ? "" : prefix);
    }
  }
  if (mParentCtxt != null) {
    Iterator it = mParentCtxt.getPrefixes(nsURI);
    if (l == null) {
      return it;
    }
    while (it.hasNext()) {
      l.add(it.next());
    }
  }
  return (l == null) ? EmptyIterator.getInstance() : l.iterator();
}

代码示例来源:origin: org.codehaus.jettison/jettison

while (namespaces.hasNext()) {
  Namespace ns = (Namespace) namespaces.next();
  String prefix = ns.getPrefix();
  String nsURI = ns.getNamespaceURI();
  streamWriter.writeNamespace(prefix, nsURI);

代码示例来源:origin: camunda/camunda-bpm-platform

for (Iterator i = event.getNamespaces(); i.hasNext();) {
  Namespace namespace = (Namespace) i.next();
  String prefix = namespace.getPrefix();
  String namespaceUri = namespace.getNamespaceURI();
  String qName;
  if (StringUtils.hasLength(prefix)) {

代码示例来源:origin: OfficeDev/ews-java-api

while (ite.hasNext()) {
 Namespace ns = (Namespace) ite.next();
 String name = ns.getPrefix();
 if (!name.isEmpty()) {
  element.setAttributeNS(xmlns, name,
    ns.getNamespaceURI());
 } else {
  xmlns = ns.getNamespaceURI();

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

/**
 * Constructs a new DOM4J Element from the provided StartElement event. All
 * attributes and namespaces will be added to the returned element.
 * 
 * @param startEvent
 *            The StartElement event from which to construct the new DOM4J
 *            Element.
 * 
 * @return The Element constructed from the provided StartElement event.
 */
public Element createElement(StartElement startEvent) {
  QName qname = startEvent.getName();
  org.dom4j.QName elemName = createQName(qname);
  Element elem = factory.createElement(elemName);
  // create attributes
  for (Iterator<Attribute> i = startEvent.getAttributes(); i.hasNext();) {
    Attribute attr = i.next();
    elem.addAttribute(createQName(attr.getName()), attr.getValue());
  }
  // create namespaces
  for (Iterator<Namespace> i = startEvent.getNamespaces(); i.hasNext();) {
    Namespace ns = i.next();
    elem.addNamespace(ns.getPrefix(), ns.getNamespaceURI());
  }
  return elem;
}

代码示例来源:origin: camunda/camunda-bpm-platform

private void handleStartElement(StartElement startElement) throws SAXException {
  if (getContentHandler() != null) {
    QName qName = startElement.getName();
    if (hasNamespacesFeature()) {
      for (Iterator i = startElement.getNamespaces(); i.hasNext();) {
        Namespace namespace = (Namespace) i.next();
        startPrefixMapping(namespace.getPrefix(), namespace.getNamespaceURI());
      }
      for (Iterator i = startElement.getAttributes(); i.hasNext();){
        Attribute attribute = (Attribute) i.next();
        QName attributeName = attribute.getName();
        startPrefixMapping(attributeName.getPrefix(), attributeName.getNamespaceURI());
      }
      getContentHandler().startElement(qName.getNamespaceURI(), qName.getLocalPart(), toQualifiedName(qName),
          getAttributes(startElement));
    }
    else {
      getContentHandler().startElement("", "", toQualifiedName(qName), getAttributes(startElement));
    }
  }
}

代码示例来源:origin: jamesagnew/hapi-fhir

case XMLStreamConstants.NAMESPACE:
  Namespace ns = (Namespace) event;
  theEventWriter.writeNamespace(ns.getPrefix(), ns.getNamespaceURI());
  break;
case XMLStreamConstants.START_ELEMENT:

相关文章