本文整理汇总了Java中org.apache.xerces.xni.XMLAttributes.getLength方法的典型用法代码示例。如果您正苦于以下问题:Java XMLAttributes.getLength方法的具体用法?Java XMLAttributes.getLength怎么用?Java XMLAttributes.getLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.xerces.xni.XMLAttributes
的用法示例。
在下文中一共展示了XMLAttributes.getLength方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: startElement
import org.apache.xerces.xni.XMLAttributes; //导入方法依赖的package包/类
public void startElement(QName element, XMLAttributes attributes,
Augmentations augs) throws XNIException {
try {
int length = attributes.getLength();
if (length == 0) {
/** Avoid creating a new StartElement event object (if possible). */
XMLEvent start = fStAXValidatorHelper.getCurrentEvent();
if (start != null) {
fEventWriter.add(start);
return;
}
}
fEventWriter.add(fEventFactory.createStartElement(element.prefix,
element.uri != null ? element.uri : "", element.localpart,
getAttributeIterator(attributes, length), getNamespaceIterator(),
fNamespaceContext.getNamespaceContext()));
}
catch (XMLStreamException e) {
throw new XNIException(e);
}
}
示例3: startElement
import org.apache.xerces.xni.XMLAttributes; //导入方法依赖的package包/类
/** Start element. */
public void startElement(QName element, XMLAttributes attrs, Augmentations augs)
throws XNIException {
fElements++;
fTagCharacters++; // open angle bracket
fTagCharacters += element.rawname.length();
if (attrs != null) {
int attrCount = attrs.getLength();
fAttributes += attrCount;
for (int i = 0; i < attrCount; i++) {
fTagCharacters++; // space
fTagCharacters += attrs.getQName(i).length();
fTagCharacters++; // '='
fTagCharacters++; // open quote
fOtherCharacters += attrs.getValue(i).length();
fTagCharacters++; // close quote
}
}
fTagCharacters++; // close angle bracket
}
示例4: emptyElement
import org.apache.xerces.xni.XMLAttributes; //导入方法依赖的package包/类
/** Empty element. */
public void emptyElement(QName element, XMLAttributes attrs, Augmentations augs)
throws XNIException {
fElements++;
fTagCharacters++; // open angle bracket
fTagCharacters += element.rawname.length();
if (attrs != null) {
int attrCount = attrs.getLength();
fAttributes += attrCount;
for (int i = 0; i < attrCount; i++) {
fTagCharacters++; // space
fTagCharacters += attrs.getQName(i).length();
fTagCharacters++; // '='
fTagCharacters++; // open quote
fOtherCharacters += attrs.getValue(i).length();
fTagCharacters++; // close quote
}
}
fTagCharacters++; // forward slash
fTagCharacters++; // close angle bracket
}
示例5: startElement
import org.apache.xerces.xni.XMLAttributes; //导入方法依赖的package包/类
/** Start element. */
public void startElement(QName element, XMLAttributes attrs, Augmentations augs)
throws XNIException {
fSeenRootElement = true;
fElementDepth++;
fOut.print('<');
fOut.print(element.rawname);
if (attrs != null) {
/***
attrs = sortAttributes(attrs);
/***/
int len = attrs.getLength();
for (int i = 0; i < len; i++) {
fOut.print(' ');
fOut.print(attrs.getQName(i));
fOut.print("=\"");
normalizeAndPrint(attrs.getValue(i));
fOut.print('"');
}
}
fOut.print('>');
fOut.flush();
}
示例6: emptyElement
import org.apache.xerces.xni.XMLAttributes; //导入方法依赖的package包/类
/** Empty element. */
public void emptyElement(QName element, XMLAttributes attrs, Augmentations augs)
throws XNIException {
fSeenRootElement = true;
fElementDepth++;
fOut.print('<');
fOut.print(element.rawname);
if (attrs != null) {
/***
attrs = sortAttributes(attrs);
/***/
int len = attrs.getLength();
for (int i = 0; i < len; i++) {
fOut.print(' ');
fOut.print(attrs.getQName(i));
fOut.print("=\"");
normalizeAndPrint(attrs.getValue(i));
fOut.print('"');
}
}
fOut.print("/>");
fOut.flush();
}
示例7: parseAttributes
import org.apache.xerces.xni.XMLAttributes; //导入方法依赖的package包/类
private void parseAttributes(XMLAttributes attrs, Stack<String> langStack, Stack<String> xmlBaseStack) {
if (attrs.getLength() > 0) attributeList = new ReaderAttributeList();
String u, n, v;
for (int i = 0; i < attrs.getLength(); i++) {
u = attrs.getURI(i);
n = attrs.getQName(i);
v = attrs.getValue(i);
if (isNamespace(n)) {
if (namespaces == null) namespaces = new HashMap<String, String>();
namespaces.put(n, v);
} else {
if (lang == null) lang = resolveLang(n, v, langStack);
if (xmlBase == null) xmlBase = resolveXmlBase(n, v, xmlBaseStack);
}
attributeList.add(u, n, v);
attributeStrings.add(n + "=\"" + v + "\"");
}
}
示例8: startElement
import org.apache.xerces.xni.XMLAttributes; //导入方法依赖的package包/类
/**
* The start of an element. If the document specifies the start element
* by using an empty tag, then the startElement method will immediately
* be followed by the endElement method, with no intervening methods.
* Overriding the parent to handle DOM_NAMESPACE_DECLARATIONS=false.
*
* @param element The name of the element.
* @param attributes The element attributes.
* @param augs Additional information that may include infoset augmentations
*
* @throws XNIException Thrown by handler to signal an error.
*/
public void startElement (QName element, XMLAttributes attributes, Augmentations augs) {
// namespace declarations parameter has no effect if namespaces is false.
if (!fNamespaceDeclarations && fNamespaceAware) {
int len = attributes.getLength();
for (int i = len - 1; i >= 0; --i) {
if (XMLSymbols.PREFIX_XMLNS == attributes.getPrefix(i) ||
XMLSymbols.PREFIX_XMLNS == attributes.getQName(i)) {
attributes.removeAttributeAt(i);
}
}
}
super.startElement(element, attributes, augs);
}
示例9: startAnnotationElement
import org.apache.xerces.xni.XMLAttributes; //导入方法依赖的package包/类
void startAnnotationElement(String elemRawName, XMLAttributes attributes) {
fAnnotationBuffer.append("<").append(elemRawName);
for(int i=0; i<attributes.getLength(); i++) {
String aValue = attributes.getValue(i);
fAnnotationBuffer.append(" ").append(attributes.getQName(i)).append("=\"").append(processAttValue(aValue)).append("\"");
}
fAnnotationBuffer.append(">");
}
示例10: hasNonSchemaAttributes
import org.apache.xerces.xni.XMLAttributes; //导入方法依赖的package包/类
/**
* @param attributes
* @return
*/
private boolean hasNonSchemaAttributes(QName element, XMLAttributes attributes) {
final int length = attributes.getLength();
for (int i = 0; i < length; ++i) {
String uri = attributes.getURI(i);
if (uri != null && uri != SchemaSymbols.URI_SCHEMAFORSCHEMA &&
uri != NamespaceContext.XMLNS_URI &&
!(uri == NamespaceContext.XML_URI &&
attributes.getQName(i) == SchemaSymbols.ATT_XML_LANG && element.localpart == SchemaSymbols.ELT_SCHEMA)) {
return true;
}
}
return false;
}
示例11: processNamespaceAttributes
import org.apache.xerces.xni.XMLAttributes; //导入方法依赖的package包/类
/**
* Write an unordered set of attribute information items, one for each of
* the namespace declarations (specified or defaulted from the DTD) of this
* element. A declaration of the form xmlns="", which undeclares the default
* namespace, counts as a namespace declaration. By definition, all
* namespace attributes (including those named xmlns, whose [prefix]
* property has no value) have a namespace URI of
* http://www.w3.org/2000/xmlns/. If the element has no namespace
* declarations, this set has no members
*/
private void processNamespaceAttributes(XMLAttributes attributes) {
// we don't need to check for null, since that was checked for in processAttributes()
int attrCount = attributes.getLength();
sendIndentedElement("namespaceAttributes");
for (int i = 0; i < attrCount; i++) {
String localpart = attributes.getLocalName(i);
String prefix = attributes.getPrefix(i);
if (!(prefix.equals(XMLSymbols.PREFIX_XMLNS)
|| localpart.equals(XMLSymbols.PREFIX_XMLNS)))
continue;
sendIndentedElement("attribute");
sendElementEvent("namespaceName", NamespaceContext.XMLNS_URI);
sendElementEvent("localName", localpart);
sendElementEvent("prefix", prefix);
sendElementEvent("normalizedValue", attributes.getValue(i));
sendElementEvent(
"specified",
String.valueOf(attributes.isSpecified(i)));
sendElementEvent("attributeType", attributes.getType(i));
// this property isn't relevent to PSVI
sendElementEvent("references");
if (fPSVInfoset) {
processPSVIAttribute(attributes.getAugmentations(i));
}
sendUnIndentedElement("attribute");
}
sendUnIndentedElement("namespaceAttributes");
}
示例12: startElement
import org.apache.xerces.xni.XMLAttributes; //导入方法依赖的package包/类
@Override
public void startElement(QName element, XMLAttributes attrs,
Augmentations augs) throws XNIException {
int i;
for (i = 0; i < attrs.getLength(); ++i) {
if (isNamespace(attrs.getQName(i))) {
attrs.removeAttributeAt(i);
--i;
}
}
element.uri = null;
super.startElement(element, attrs, augs);
}
示例13: getValue
import org.apache.xerces.xni.XMLAttributes; //导入方法依赖的package包/类
/** Returns the value of the specified attribute, ignoring case. */
protected static String getValue(XMLAttributes attrs, String aname) {
int length = attrs != null ? attrs.getLength() : 0;
for (int i = 0; i < length; i++) {
if (attrs.getQName(i).equalsIgnoreCase(aname)) {
return attrs.getValue(i);
}
}
return null;
}
示例14: startElement
import org.apache.xerces.xni.XMLAttributes; //导入方法依赖的package包/类
/** Start element. */
public void startElement(QName element, XMLAttributes attrs,
Augmentations augs) throws XNIException {
Element elementNode = fDocument.createElement(element.rawname);
int count = attrs != null ? attrs.getLength() : 0;
for (int i = 0; i < count; i++) {
String aname = attrs.getQName(i);
String avalue = attrs.getValue(i);
if (XMLChar.isValidName(aname)) {
elementNode.setAttribute(aname, avalue);
}
}
fCurrentNode.appendChild(elementNode);
fCurrentNode = elementNode;
}
示例15: handleOpenTag
import org.apache.xerces.xni.XMLAttributes; //导入方法依赖的package包/类
/** Handles an open tag. */
protected boolean handleOpenTag(QName element, XMLAttributes attributes) {
if (elementAccepted(element.rawname)) {
Object key = element.rawname.toLowerCase();
Object value = fAcceptedElements.get(key);
if (value != NULL) {
String[] anames = (String[])value;
int attributeCount = attributes.getLength();
LOOP: for (int i = 0; i < attributeCount; i++) {
String aname = attributes.getQName(i).toLowerCase();
for (int j = 0; j < anames.length; j++) {
if (anames[j].equals(aname)) {
continue LOOP;
}
}
attributes.removeAttributeAt(i--);
attributeCount--;
}
}
else {
attributes.removeAllAttributes();
}
return true;
}
else if (elementRemoved(element.rawname)) {
fRemovalElementDepth = fElementDepth;
}
return false;
}