nu.xom.Element.getNamespacePrefix()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(10.1k)|赞(0)|评价(0)|浏览(138)

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

Element.getNamespacePrefix介绍

暂无

代码示例

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

public String getNamespacePrefix(Object o) {
  if (isElement(o)) {
    return ((Element)o).getNamespacePrefix();
  } else if (isAttribute(o)) {
    return ((Attribute)o).getNamespacePrefix();
  } else if (o instanceof XPathNamespace) {
    return ((XPathNamespace)o).getNamespacePrefix();
  }
  return null;
}

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

public Iterator getNamespaceAxisIterator(Object o)
  {
    if (! isElement(o)) {
      return JaxenConstants.EMPTY_ITERATOR;
    }
    Map nsMap = new HashMap();
    Element elt = (Element)o;
    ParentNode parent = elt;
    
    while (parent instanceof Element) {
      elt = (Element)parent;
      String uri    = elt.getNamespaceURI();
      String prefix = elt.getNamespacePrefix();
      addNamespaceForElement(elt, uri, prefix, nsMap);
      int count = elt.getNamespaceDeclarationCount();
      for (int i = 0; i < count; i++) {
        prefix = elt.getNamespacePrefix(i);
        uri    = elt.getNamespaceURI(prefix);
        addNamespaceForElement(elt, uri, prefix, nsMap);
      }
      parent = elt.getParent();
    }
    addNamespaceForElement(elt, "http://www.w3.org/XML/1998/namespace", "xml", nsMap);

    return nsMap.values().iterator();
  }
}

代码示例来源:origin: org.teiid/saxon-xom

/**
 * Get the prefix of the name of the node. This is defined only for elements and attributes.
 * If the node has no prefix, or for other kinds of node, return a zero-length string.
 *
 * @return The prefix of the name of the node.
 */
public String getPrefix() {
  switch (nodeKind) {
    case Type.ELEMENT:
      return ((Element) node).getNamespacePrefix();
    case Type.ATTRIBUTE:
      return ((Attribute) node).getNamespacePrefix();
    default:
      return "";
  }
}

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

/**
 * Get the prefix of the name of the node. This is defined only for elements and attributes.
 * If the node has no prefix, or for other kinds of node, return a zero-length string.
 *
 * @return The prefix of the name of the node.
 */
public String getPrefix() {
  switch (nodeKind) {
    case Type.ELEMENT:
      return ((Element) node).getNamespacePrefix();
    case Type.ATTRIBUTE:
      return ((Attribute) node).getNamespacePrefix();
    default:
      return "";
  }
}

代码示例来源:origin: org.jboss.teiid/teiid-engine

/**
 * Get the prefix of the name of the node. This is defined only for elements and attributes.
 * If the node has no prefix, or for other kinds of node, return a zero-length string.
 *
 * @return The prefix of the name of the node.
 */
public String getPrefix() {
  switch (nodeKind) {
    case Type.ELEMENT:
      return ((Element) node).getNamespacePrefix();
    case Type.ATTRIBUTE:
      return ((Attribute) node).getNamespacePrefix();
    default:
      return "";
  }
}

代码示例来源:origin: org.xml-cml/cmlxom

/**
 * @param node
 * @param count
 */
private static List<String> getNamespaceURIList(Element node) {
  List<String> namespaceURIList = new ArrayList<String>();
  for (int i = 0; i < node.getNamespaceDeclarationCount(); i++) {
    String prefix = node.getNamespacePrefix(i);
    String refNamespaceURI = node.getNamespaceURI(prefix);
    namespaceURIList.add(refNamespaceURI);
  }
  return namespaceURIList;
}

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

/**
   * If the prefix for the Concordion namespace is something other than "concordion", eg "c", this 
   * updates the stylesheet to use the prefix.
   * This is required since <a href="http://stackoverflow.com/questions/24628932/do-css-namespace-attribute-selectors-work-with-xhtml-html-elements">
   * namespaced CSS selectors generally don't work with HTML</a>, so <code>embedded.css</code> uses hardcoded namespace prefixes (eg. <code>[concordion\:example]</code>).
   */
  private String updateConcordionNamespacePrefix(Element html, String stylesheetContent) {
    for (int i=0; i<html.getNamespaceDeclarationCount(); i++) {
      String prefix = html.getNamespacePrefix(i);
      if (ConcordionBuilder.NAMESPACE_CONCORDION_2007.equals(html.getNamespaceURI(prefix))) {
        return stylesheetContent.replace("concordion\\:", prefix + "\\:");
      }
    }
    return stylesheetContent;
  }
}

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

/**
   * If the prefix for the Concordion namespace is something other than "concordion", eg "c", this 
   * updates the stylesheet to use the prefix.
   * This is required since <a href="http://stackoverflow.com/questions/24628932/do-css-namespace-attribute-selectors-work-with-xhtml-html-elements">
   * namespaced CSS selectors generally don't work with HTML</a>, so <code>embedded.css</code> uses hardcoded namespace prefixes (eg. <code>[concordion\:example]</code>).
   */
  private String updateConcordionNamespacePrefix(Element html, String stylesheetContent) {
    for (int i=0; i<html.getNamespaceDeclarationCount(); i++) {
      String prefix = html.getNamespacePrefix(i);
      if (ConcordionBuilder.NAMESPACE_CONCORDION_2007.equals(html.getNamespaceURI(prefix))) {
        return stylesheetContent.replace("concordion\\:", prefix + "\\:");
      }
    }
    return stylesheetContent;
  }
}

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

public XmlName(Element element) {
  this.prefix = element.getNamespacePrefix();
  this.localName = element.getLocalName();
  this.namespace = element.getNamespaceURI();
}

代码示例来源:origin: org.dspace/dspace-sword-api

public XmlName(Element element)
{
  this.prefix = element.getNamespacePrefix();
  this.localName = element.getLocalName();
  this.namespace = element.getNamespaceURI();
}

代码示例来源:origin: org.swordapp/sword-common

public XmlName(Element element)
{
  this.prefix = element.getNamespacePrefix();
  this.localName = element.getLocalName();
  this.namespace = element.getNamespaceURI();
}

代码示例来源:origin: org.teiid/saxon-xom

private static Map getNamespacePrefixesInScopeNonPublic(Element element) {
  HashMap namespaces = new HashMap();
  
  do {
    int size = element.getNamespaceDeclarationCount();
    for (int i = 0; i < size; i++) {
      String prefix = element.getNamespacePrefix(i);
      if (!namespaces.containsKey(prefix)) {
        String uri = element.getNamespaceURI(prefix);
        namespaces.put(prefix, uri);
      }
    }
    ParentNode parent = element.getParent();
    element = (parent instanceof Element ? (Element) parent : null);
  } while (element != null);
  
  return namespaces;
}

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

private static Map getNamespacePrefixesInScopeNonPublic(Element element) {
  HashMap namespaces = new HashMap();
  
  do {
    int size = element.getNamespaceDeclarationCount();
    for (int i = 0; i < size; i++) {
      String prefix = element.getNamespacePrefix(i);
      if (!namespaces.containsKey(prefix)) {
        String uri = element.getNamespaceURI(prefix);
        namespaces.put(prefix, uri);
      }
    }
    ParentNode parent = element.getParent();
    element = (parent instanceof Element ? (Element) parent : null);
  } while (element != null);
  
  return namespaces;
}

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

private void writeNamespaceDeclarations(Element elem) {
    int count = elem.getNamespaceDeclarationCount();
    if (count == 1) 
      return; // elem.getNamespaceURI() has already been written

    for (int i = 0; i < count; i++) {
      String prefix = elem.getNamespacePrefix(i);
      String uri = elem.getNamespaceURI(prefix);
      if (prefix.equals(elem.getNamespacePrefix()) && uri.equals(elem.getNamespaceURI())) {
//                if (DEBUG) System.err.println("********** NAMESPACE IGNORED ON WRITE ***************\n");
        continue;
      }
      nodeTokens.add((byte)NAMESPACE_DECLARATION);
      writeIndex(prefix);
      writeIndex(uri);
    }
  }

代码示例来源:origin: org.teiid/saxon-xom

private void writeNamespaceDeclarations(Element elem) {
    int count = elem.getNamespaceDeclarationCount();
    if (count == 1) 
      return; // elem.getNamespaceURI() has already been written

    for (int i = 0; i < count; i++) {
      String prefix = elem.getNamespacePrefix(i);
      String uri = elem.getNamespaceURI(prefix);
      if (prefix.equals(elem.getNamespacePrefix()) && uri.equals(elem.getNamespaceURI())) {
//                if (DEBUG) System.err.println("********** NAMESPACE IGNORED ON WRITE ***************\n");
        continue;
      }
      nodeTokens.add((byte)NAMESPACE_DECLARATION);
      writeIndex(prefix);
      writeIndex(uri);
    }
  }

代码示例来源:origin: se.vgregion.pubsubhubbub/pubsubhubbub-hub-composite-pubsub

public DefaultField(Element elm) {
  this.name = elm.getLocalName();
  this.namespace = elm.getNamespaceURI();
  this.prefix = elm.getNamespacePrefix();
  
  for(int i = 0; i<elm.getAttributeCount(); i++) {
    Attribute attribute = elm.getAttribute(i);
    fields.add(new DefaultField(attribute.getNamespaceURI(), attribute.getNamespacePrefix(), attribute.getLocalName(), attribute.getValue()));
  }
  
  this.content = XmlUtil.innerToString(elm);
}

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

final void writeStartTag(Element elem) {
  writeIndex(elem.getNamespacePrefix(), elem.getLocalName());
  int type = BEGIN_ELEMENT;
  if (elem.getNamespaceURI().length() == 0) {
    type = Util.noNamespace(type);
  } else {
    writeIndex(elem.getNamespaceURI());
  }
  nodeTokens.add((byte)type);
  
  for (int i = 0; i < elem.getAttributeCount(); i++) {
    writeAttribute(elem.getAttribute(i));
  }
  
  writeNamespaceDeclarations(elem);
}

代码示例来源:origin: org.teiid/saxon-xom

final void writeStartTag(Element elem) {
  writeIndex(elem.getNamespacePrefix(), elem.getLocalName());
  int type = BEGIN_ELEMENT;
  if (elem.getNamespaceURI().length() == 0) {
    type = Util.noNamespace(type);
  } else {
    writeIndex(elem.getNamespaceURI());
  }
  nodeTokens.add((byte)type);
  
  for (int i = 0; i < elem.getAttributeCount(); i++) {
    writeAttribute(elem.getAttribute(i));
  }
  
  writeNamespaceDeclarations(elem);
}

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

protected SwordValidationInfo handleIncorrectElement(Element element, Properties validationProperties)
  throws UnmarshallException {
  log.error(
    "Unexpected element. Expected: " + getQualifiedName() + ". Got: " +
      ((element != null) ? element.getQualifiedName() : "null"));
  if (validationProperties != null) {
    SwordValidationInfo info = new SwordValidationInfo(
      new XmlName(element.getNamespacePrefix(), element.getLocalName(),
            element.getNamespaceURI()),
      "This is not the expected element. Received: " +
        element.getQualifiedName() + " for namespaceUri: " +
        element.getNamespaceURI(), SwordValidationInfoType.ERROR
    );
    return info;
  } else {
    throw new UnmarshallException("Not a " + getQualifiedName() + " element");
  }
}

代码示例来源:origin: org.swordapp/sword-common

protected SwordValidationInfo handleIncorrectElement(Element element, Properties validationProperties)
throws UnmarshallException
{
  log.error("Unexpected element. Expected: " + getQualifiedName() + ". Got: " +
        ((element != null) ? element.getQualifiedName() : "null" ));
  if( validationProperties != null )
  {
   SwordValidationInfo info = new SwordValidationInfo(
        new XmlName(element.getNamespacePrefix(), element.getLocalName(), element.getNamespaceURI()),
        "This is not the expected element. Received: " + element.getQualifiedName() + " for namespaceUri: " + element.getNamespaceURI(),
        SwordValidationInfoType.ERROR
        );
   return info;
  }
  else
  {
    throw new UnmarshallException( "Not a " + getQualifiedName() + " element" );
  }
}

相关文章