本文整理汇总了Java中org.apache.xerces.xni.XMLAttributes.addAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java XMLAttributes.addAttribute方法的具体用法?Java XMLAttributes.addAttribute怎么用?Java XMLAttributes.addAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.xerces.xni.XMLAttributes
的用法示例。
在下文中一共展示了XMLAttributes.addAttribute方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Info
import org.apache.xerces.xni.XMLAttributes; //导入方法依赖的package包/类
/**
* Creates an element information object.
* <p>
* <strong>Note:</strong>
* This constructor makes a copy of the element information.
*
* @param element The element qualified name.
* @param attributes The element attributes.
*/
public Info(HTMLElements.Element element,
QName qname, XMLAttributes attributes) {
this.element = element;
this.qname = new QName(qname);
if (attributes != null) {
int length = attributes.getLength();
if (length > 0) {
QName aqname = new QName();
XMLAttributes newattrs = new XMLAttributesImpl();
for (int i = 0; i < length; i++) {
attributes.getName(i, aqname);
String type = attributes.getType(i);
String value = attributes.getValue(i);
String nonNormalizedValue = attributes.getNonNormalizedValue(i);
boolean specified = attributes.isSpecified(i);
newattrs.addAttribute(aqname, type, value);
newattrs.setNonNormalizedValue(i, nonNormalizedValue);
newattrs.setSpecified(i, specified);
}
this.attributes = newattrs;
}
}
}
示例2: synthesizeBinding
import org.apache.xerces.xni.XMLAttributes; //导入方法依赖的package包/类
/** Synthesize namespace binding. */
protected void synthesizeBinding(XMLAttributes attrs, String ns) {
String prefix = "xmlns";
String localpart = ns;
String qname = prefix+':'+localpart;
String uri = NamespaceBinder.NAMESPACES_URI;
String atype = "CDATA";
String avalue = SYNTHESIZED_NAMESPACE_PREFX+fSynthesizedNamespaceCount++;
// add attribute
fQName.setValues(prefix, localpart, qname, uri);
attrs.addAttribute(fQName, atype, avalue);
// bind namespace
XercesBridge.getInstance().NamespaceContext_declarePrefix(fNamespaceContext, ns, avalue);
}
示例3: createAttributes
import org.apache.xerces.xni.XMLAttributes; //导入方法依赖的package包/类
private XMLAttributes createAttributes(Vector atts) {
XMLAttributes attributes = new XMLAttributesImpl();
if (atts != null) {
for (int i = 0; i < atts.size(); i += 3) {
String rawname = (String)atts.elementAt(i);
String value = (String)atts.elementAt(i + 1);
String type = (String)atts.elementAt(i + 2);
attributes.addAttribute(createQName(rawname), type, value);
}
}
return attributes;
}
示例4: scanAttribute
import org.apache.xerces.xni.XMLAttributes; //导入方法依赖的package包/类
/**
* Scans an attribute.
* <p>
* <pre>
* [41] Attribute ::= Name Eq AttValue
* </pre>
* <p>
* <strong>Note:</strong> This method assumes that the next
* character on the stream is the first character of the attribute
* name.
* <p>
* <strong>Note:</strong> This method uses the fAttributeQName and
* fQName variables. The contents of these variables will be
* destroyed.
*
* @param attributes The attributes list for the scanned attribute.
*/
protected void scanAttribute(XMLAttributes attributes)
throws IOException, XNIException {
if (DEBUG_CONTENT_SCANNING) System.out.println(">>> scanAttribute()");
// name
if (fNamespaces) {
fEntityScanner.scanQName(fAttributeQName);
}
else {
String name = fEntityScanner.scanName();
fAttributeQName.setValues(null, name, name, null);
}
// equals
fEntityScanner.skipSpaces();
if (!fEntityScanner.skipChar('=')) {
reportFatalError("EqRequiredInAttribute",
new Object[]{fCurrentElement.rawname,fAttributeQName.rawname});
}
fEntityScanner.skipSpaces();
// content
int oldLen = attributes.getLength();
int attrIndex = attributes.addAttribute(fAttributeQName, XMLSymbols.fCDATASymbol, null);
// WFC: Unique Att Spec
if (oldLen == attributes.getLength()) {
reportFatalError("AttributeNotUnique",
new Object[]{fCurrentElement.rawname,
fAttributeQName.rawname});
}
// Scan attribute value and return true if the un-normalized and normalized value are the same
boolean isSameNormalizedAttr = scanAttributeValue(fTempString, fTempString2,
fAttributeQName.rawname, fIsEntityDeclaredVC, fCurrentElement.rawname);
attributes.setValue(attrIndex, fTempString.toString());
// If the non-normalized and normalized value are the same, avoid creating a new string.
if (!isSameNormalizedAttr) {
attributes.setNonNormalizedValue(attrIndex, fTempString2.toString());
}
attributes.setSpecified(attrIndex, true);
if (DEBUG_CONTENT_SCANNING) System.out.println("<<< scanAttribute()");
}
示例5: processDOMElement
import org.apache.xerces.xni.XMLAttributes; //导入方法依赖的package包/类
private void processDOMElement(
Node node,
String elementName,
String tagName) {
if (node == null)
return;
boolean foundElem = false;
for (Element child = DOMUtil.getFirstChildElement(node);
child != null;
child = DOMUtil.getNextSiblingElement(child)) {
if (DOMUtil.getLocalName(child).equals(elementName)) {
if (!foundElem) {
sendIndentedElement(tagName);
foundElem = true;
}
sendIndentedElement("element");
sendElementEvent(
"namespaceName",
DOMUtil.getNamespaceURI(child));
sendElementEvent("localName", DOMUtil.getLocalName(child));
sendElementEvent("prefix", child.getPrefix());
sendIndentedElement("children");
sendIndentedElement("character");
sendElementEvent("textContent", DOMUtil.getChildText(child));
sendUnIndentedElement("character");
sendUnIndentedElement("children");
//Create XMLAttributes from DOM
Attr[] atts = (Element) child == null ? null : DOMUtil.getAttrs((Element) child);
XMLAttributes attrs = new XMLAttributesImpl();
for (int i=0; i<atts.length; i++) {
Attr att = (Attr)atts[i];
attrs.addAttribute(
new QName(att.getPrefix(), att.getLocalName(), att.getName(), att.getNamespaceURI()),
"CDATA" ,att.getValue()
);
}
processAttributes(attrs);
sendUnIndentedElement("element");
}
}
if (foundElem) {
sendUnIndentedElement(tagName);
}
else {
sendEmptyElementEvent(tagName);
}
}