org.apache.xerces.util.XMLAttributesImpl.addAttributeNS()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(5.9k)|赞(0)|评价(0)|浏览(181)

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

XMLAttributesImpl.addAttributeNS介绍

[英]Adds an attribute. The attribute's non-normalized value of the attribute will have the same value as the attribute value until set using the setNonNormalizedValue method. Also, the added attribute will be marked as specified in the XML instance document unless set otherwise using the setSpecified method.

This method differs from addAttribute in that it does not check if an attribute of the same name already exists in the list before adding it. In order to improve performance of namespace processing, this method allows uniqueness checks to be deferred until all the namespace information is available after the entire attribute specification has been read.

Caution: If this method is called it should not be mixed with calls to addAttribute unless it has been determined that all the attribute names are unique.
[中]添加一个属性。在使用setNonNormalizedValue方法设置之前,属性的非规范化值将与属性值具有相同的值。此外,添加的属性将被标记为XML实例文档中指定的属性,除非使用setSpecified方法另行设置。
此方法与addAttribute的不同之处在于,在添加属性之前,它不会检查列表中是否已存在同名属性。为了提高名称空间处理的性能,此方法允许在读取整个属性规范后,将唯一性检查推迟到所有名称空间信息可用为止。
警告:如果调用此方法,则不应将其与对addAttribute的调用混合使用,除非已确定所有属性名称都是唯一的。

代码示例

代码示例来源:origin: org.seasar.teeda/teeda-extension

public void addAttributeNS(QName name, String type, String value) {
  attributes.addAttributeNS(name, type, value);
}

代码示例来源:origin: com.rackspace.apache/xerces2-xsd11

/** Adds an attribute to the XMLAttributes object. */
private void fillXMLAttribute(Attributes att, int index) {
  fillQName(fAttributeQName, att.getURI(index), att.getLocalName(index), att.getQName(index));
  String type = att.getType(index);
  fAttributes.addAttributeNS(fAttributeQName, (type != null) ? type : XMLSymbols.fCDATASymbol, att.getValue(index));
}

代码示例来源:origin: com.rackspace.apache/xerces2-xsd11

private void fillXMLAttributes(Attributes atts) {
  fAttributes.removeAllAttributes();
  final int attrCount = atts.getLength();
  for (int i = 0; i < attrCount; ++i) {
    fillQName(fAttributeQName, atts.getURI(i), atts.getLocalName(i), atts.getQName(i));
    String type = atts.getType(i);
    fAttributes.addAttributeNS(fAttributeQName, (type != null) ? type : XMLSymbols.fCDATASymbol, atts.getValue(i));
    fAttributes.setSpecified(i, true);
  }
}

代码示例来源:origin: com.rackspace.apache/xerces2-xsd11

private void fillXMLAttributes(StartElement event) {
  fAttributes.removeAllAttributes();
  final Iterator attrs = event.getAttributes();
  while (attrs.hasNext()) {
    Attribute attr = (Attribute) attrs.next();
    fillQName(fAttributeQName, attr.getName());
    String type = attr.getDTDType();
    int idx = fAttributes.getLength();
    fAttributes.addAttributeNS(fAttributeQName, 
        (type != null) ? type : XMLSymbols.fCDATASymbol, attr.getValue());
    fAttributes.setSpecified(idx, attr.isSpecified());
  }
}

代码示例来源:origin: com.rackspace.apache/xerces2-xsd11

private void fillXMLAttributes(XMLStreamReader input) {
  fAttributes.removeAllAttributes();
  final int len = input.getAttributeCount();
  for (int i = 0; i < len; ++i) {
    fillQName(fAttributeQName, input.getAttributeNamespace(i), 
      input.getAttributeLocalName(i), input.getAttributePrefix(i));
    String type = input.getAttributeType(i);
    fAttributes.addAttributeNS(fAttributeQName, 
        (type != null) ? type : XMLSymbols.fCDATASymbol, input.getAttributeValue(i));
    fAttributes.setSpecified(i, input.isAttributeSpecified(i));
  }
}

代码示例来源:origin: com.rackspace.apache/xerces2-xsd11

/** Fills in the XMLAttributes object. */
private void fillXMLAttributes(StartElement event) {
  fAttributes.removeAllAttributes();
  final Iterator attrs = event.getAttributes();
  while (attrs.hasNext()) {
    Attribute attr = (Attribute) attrs.next();
    fillQName(fAttributeQName, attr.getName());
    String type = attr.getDTDType();
    int idx = fAttributes.getLength();
    fAttributes.addAttributeNS(fAttributeQName, 
        (type != null) ? type : XMLSymbols.fCDATASymbol, attr.getValue());
    fAttributes.setSpecified(idx, attr.isSpecified());
  }
}

代码示例来源:origin: com.rackspace.apache/xerces2-xsd11

/** Fills in the XMLAttributes object. */
private void fillXMLAttributes(XMLStreamReader reader) {
  fAttributes.removeAllAttributes();
  final int len = reader.getAttributeCount();
  for (int i = 0; i < len; ++i) {
    fillQName(fAttributeQName, reader.getAttributeNamespace(i), 
        reader.getAttributeLocalName(i), reader.getAttributePrefix(i));
    String type = reader.getAttributeType(i);
    fAttributes.addAttributeNS(fAttributeQName, 
        (type != null) ? type : XMLSymbols.fCDATASymbol, reader.getAttributeValue(i));
    fAttributes.setSpecified(i, reader.isAttributeSpecified(i));
  }
}

代码示例来源:origin: com.rackspace.apache/xerces2-xsd11

private void processAttributes(NamedNodeMap attrMap) {
  final int attrCount = attrMap.getLength();
  fAttributes.removeAllAttributes();
  for (int i = 0; i < attrCount; ++i) {
    Attr attr = (Attr) attrMap.item(i);
    String value = attr.getValue();
    if (value == null) {
      value = XMLSymbols.EMPTY_STRING;
    }
    fillQName(fAttributeQName, attr);
    // REVISIT: Assuming all attributes are of type CDATA. The actual type may not matter. -- mrglavas
    fAttributes.addAttributeNS(fAttributeQName, XMLSymbols.fCDATASymbol, value);
    fAttributes.setSpecified(i, attr.getSpecified());
    // REVISIT: Should we be looking at non-namespace attributes
    // for additional mappings? Should we detect illegal namespace
    // declarations and exclude them from the context? -- mrglavas
    if (fAttributeQName.uri == NamespaceContext.XMLNS_URI) {
      // process namespace attribute
      if (fAttributeQName.prefix == XMLSymbols.PREFIX_XMLNS) {
        fNamespaceContext.declarePrefix(fAttributeQName.localpart, value.length() != 0 ? fSymbolTable.addSymbol(value) : null);
      }
      else {
        fNamespaceContext.declarePrefix(XMLSymbols.EMPTY_STRING, value.length() != 0 ? fSymbolTable.addSymbol(value) : null);
      }
    }
  }
}

代码示例来源:origin: com.rackspace.apache/xerces2-xsd11

attributes.addAttributeNS(fAttributeQName, XMLSymbols.fCDATASymbol, null);

代码示例来源:origin: com.rackspace.apache/xerces2-xsd11

attributes.addAttributeNS(
  fAttributeQName,
  XMLSymbols.fCDATASymbol,

代码示例来源:origin: com.rackspace.apache/xerces2-xsd11

XMLAttributesImpl attrs = (XMLAttributesImpl) attributes;
attrIndex = attrs.getLength();
attrs.addAttributeNS(attName, "CDATA", normalized);

相关文章