当前位置: 首页>>代码示例>>Java>>正文


Java XMLAttributes.getLength方法代码示例

本文整理汇总了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;
        }
    }
}
 
开发者ID:carson0321,项目名称:node-boilerpipe,代码行数:33,代码来源:HTMLTagBalancer.java

示例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);
    }
}
 
开发者ID:AaronZhangL,项目名称:SplitCharater,代码行数:22,代码来源:StAXEventResultBuilder.java

示例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

}
 
开发者ID:AaronZhangL,项目名称:SplitCharater,代码行数:23,代码来源:Counter.java

示例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

}
 
开发者ID:AaronZhangL,项目名称:SplitCharater,代码行数:24,代码来源:Counter.java

示例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();

}
 
开发者ID:AaronZhangL,项目名称:SplitCharater,代码行数:26,代码来源:Writer.java

示例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();

}
 
开发者ID:AaronZhangL,项目名称:SplitCharater,代码行数:26,代码来源:Writer.java

示例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 + "\"");
    }
}
 
开发者ID:gocd,项目名称:gocd,代码行数:19,代码来源:ReaderNode.java

示例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);
}
 
开发者ID:AaronZhangL,项目名称:SplitCharater,代码行数:26,代码来源:DOMParserImpl.java

示例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(">");
}
 
开发者ID:AaronZhangL,项目名称:SplitCharater,代码行数:9,代码来源:SchemaDOM.java

示例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;
}
 
开发者ID:AaronZhangL,项目名称:SplitCharater,代码行数:18,代码来源:SchemaDOMParser.java

示例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");

}
 
开发者ID:AaronZhangL,项目名称:SplitCharater,代码行数:42,代码来源:PSVIWriter.java

示例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);
}
 
开发者ID:gocd,项目名称:gocd,代码行数:15,代码来源:HtmlDomParserContext.java

示例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;
}
 
开发者ID:ecologylab,项目名称:BigSemanticsJava,代码行数:11,代码来源:HTMLScanner.java

示例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;
}
 
开发者ID:ecologylab,项目名称:BigSemanticsJava,代码行数:16,代码来源:DOMFragmentParser.java

示例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;
}
 
开发者ID:ecologylab,项目名称:BigSemanticsJava,代码行数:30,代码来源:ElementRemover.java


注:本文中的org.apache.xerces.xni.XMLAttributes.getLength方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。