當前位置: 首頁>>代碼示例>>Java>>正文


Java XMLStreamConstants.ATTRIBUTE屬性代碼示例

本文整理匯總了Java中javax.xml.stream.XMLStreamConstants.ATTRIBUTE屬性的典型用法代碼示例。如果您正苦於以下問題:Java XMLStreamConstants.ATTRIBUTE屬性的具體用法?Java XMLStreamConstants.ATTRIBUTE怎麽用?Java XMLStreamConstants.ATTRIBUTE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在javax.xml.stream.XMLStreamConstants的用法示例。


在下文中一共展示了XMLStreamConstants.ATTRIBUTE屬性的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getEventName

/**
 * Get the human readable event name for the numeric event id
 */
public static String getEventName(int eventId) {
	switch (eventId) {
		case XMLStreamConstants.START_ELEMENT:
			return "StartElementEvent";
		case XMLStreamConstants.END_ELEMENT:
			return "EndElementEvent";
		case XMLStreamConstants.PROCESSING_INSTRUCTION:
			return "ProcessingInstructionEvent";
		case XMLStreamConstants.CHARACTERS:
			return "CharacterEvent";
		case XMLStreamConstants.COMMENT:
			return "CommentEvent";
		case XMLStreamConstants.START_DOCUMENT:
			return "StartDocumentEvent";
		case XMLStreamConstants.END_DOCUMENT:
			return "EndDocumentEvent";
		case XMLStreamConstants.ENTITY_REFERENCE:
			return "EntityReferenceEvent";
		case XMLStreamConstants.ATTRIBUTE:
			return "AttributeBase";
		case XMLStreamConstants.DTD:
			return "DTDEvent";
		case XMLStreamConstants.CDATA:
			return "CDATA";
	}
	return "UNKNOWN_EVENT_TYPE";
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:30,代碼來源:XMLStreamConstantsUtils.java

示例2: getAttributes

/**
 * Get the attributes associated with the given START_ELEMENT or ATTRIBUTE
 * StAXevent.
 *
 * @return the StAX attributes converted to an org.xml.sax.Attributes
 */
private Attributes getAttributes() {
    AttributesImpl attrs = new AttributesImpl();

    int eventType = staxStreamReader.getEventType();
    if (eventType != XMLStreamConstants.ATTRIBUTE
        && eventType != XMLStreamConstants.START_ELEMENT) {
        throw new InternalError(
            "getAttributes() attempting to process: " + eventType);
    }

    // in SAX, namespace declarations are not part of attributes by default.
    // (there's a property to control that, but as far as we are concerned
    // we don't use it.) So don't add xmlns:* to attributes.

    // gather non-namespace attrs
    for (int i = 0; i < staxStreamReader.getAttributeCount(); i++) {
        String uri = staxStreamReader.getAttributeNamespace(i);
        if(uri==null)   uri="";
        String localName = staxStreamReader.getAttributeLocalName(i);
        String prefix = staxStreamReader.getAttributePrefix(i);
        String qName;
        if(prefix==null || prefix.length()==0)
            qName = localName;
        else
            qName = prefix + ':' + localName;
        String type = staxStreamReader.getAttributeType(i);
        String value = staxStreamReader.getAttributeValue(i);

        attrs.addAttribute(uri, localName, qName, type, value);
    }

    return attrs;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:39,代碼來源:XMLStreamReaderToContentHandler.java

示例3: getEventTypeString

public final static String getEventTypeString(int eventType) {
    switch (eventType){
        case XMLStreamConstants.START_ELEMENT:
            return "START_ELEMENT";
        case XMLStreamConstants.END_ELEMENT:
            return "END_ELEMENT";
        case XMLStreamConstants.PROCESSING_INSTRUCTION:
            return "PROCESSING_INSTRUCTION";
        case XMLStreamConstants.CHARACTERS:
            return "CHARACTERS";
        case XMLStreamConstants.COMMENT:
            return "COMMENT";
        case XMLStreamConstants.START_DOCUMENT:
            return "START_DOCUMENT";
        case XMLStreamConstants.END_DOCUMENT:
            return "END_DOCUMENT";
        case XMLStreamConstants.ENTITY_REFERENCE:
            return "ENTITY_REFERENCE";
        case XMLStreamConstants.ATTRIBUTE:
            return "ATTRIBUTE";
        case XMLStreamConstants.DTD:
            return "DTD";
        case XMLStreamConstants.CDATA:
            return "CDATA";
    }
    return "UNKNOWN_EVENT_TYPE";
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:27,代碼來源:Util.java

示例4: correctPrefix

/**
 *
 * @param uri
 * @return
 */
private void correctPrefix(QName attr, int type) {
    String tmpPrefix;
    String prefix;
    String uri;
    prefix = attr.prefix;
    uri = attr.uri;
    boolean isSpecialCaseURI = false;

    if (prefix == null || prefix.equals(XMLConstants.DEFAULT_NS_PREFIX)) {
        if (uri == null) {
            return;
        }

        if (XMLConstants.DEFAULT_NS_PREFIX.equals(prefix) && uri.equals(XMLConstants.DEFAULT_NS_PREFIX))
            return;

        uri = fSymbolTable.addSymbol(uri);

        QName decl;

        for (int i = 0; i < fNamespaceDecls.size(); i++) {
            decl = fNamespaceDecls.get(i);

            if ((decl != null) && (decl.uri.equals(attr.uri))) {
                attr.prefix = decl.prefix;

                return;
            }
        }

        tmpPrefix = fNamespaceContext.getPrefix(uri);

        if (XMLConstants.DEFAULT_NS_PREFIX.equals(tmpPrefix)) {
            if (type == XMLStreamConstants.START_ELEMENT) {
                return;
            }
            else if (type == XMLStreamConstants.ATTRIBUTE) {
                //the uri happens to be the same as that of the default namespace
                tmpPrefix = getAttrPrefix(uri);
                isSpecialCaseURI = true;
            }
        }

        if (tmpPrefix == null) {
            StringBuilder genPrefix = new StringBuilder("zdef");

            for (int i = 0; i < 1; i++) {
                genPrefix.append(fPrefixGen.nextInt());
            }

            prefix = genPrefix.toString();
            prefix = fSymbolTable.addSymbol(prefix);
        } else {
            prefix = fSymbolTable.addSymbol(tmpPrefix);
        }

        if (tmpPrefix == null) {
            if (isSpecialCaseURI) {
                addAttrNamespace(prefix, uri);
            } else {
                QName qname = new QName();
                qname.setValues(prefix, XMLConstants.XMLNS_ATTRIBUTE, null, uri);
                fNamespaceDecls.add(qname);
                fInternalNamespaceContext.declarePrefix(fSymbolTable.addSymbol(
                    prefix), uri);
            }
        }
    }

    attr.prefix = prefix;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:76,代碼來源:XMLStreamWriterImpl.java


注:本文中的javax.xml.stream.XMLStreamConstants.ATTRIBUTE屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。