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


Java XMLConstants.DEFAULT_NS_PREFIX屬性代碼示例

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


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

示例1: writeAttributeWithPrefix

private void writeAttributeWithPrefix(String prefix, String localName,
    String value) throws IOException {
    fWriter.write(SPACE);

    if ((prefix != null) && (prefix != XMLConstants.DEFAULT_NS_PREFIX)) {
        fWriter.write(prefix);
        fWriter.write(":");
    }

    fWriter.write(localName);
    fWriter.write("=\"");
    writeXMLContent(value,
            true,   // true = escapeChars
            true);  // true = escapeDoubleQuotes
    fWriter.write("\"");
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:16,代碼來源:XMLStreamWriterImpl.java

示例2: fillNamespaceAttributes

protected void fillNamespaceAttributes(EndElementEvent event, XMLStreamReader xmlr) {
    int count = xmlr.getNamespaceCount();
    String uri = null;
    String prefix = null;
    NamespaceImpl attr = null;
    for (int i = 0; i < count; i++) {
        uri = xmlr.getNamespaceURI(i);
        prefix = xmlr.getNamespacePrefix(i);
        if (prefix == null) {
            prefix = XMLConstants.DEFAULT_NS_PREFIX;
        }
        attr = new NamespaceImpl(prefix, uri);
        event.addNamespace(attr);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:15,代碼來源:XMLEventAllocatorImpl.java

示例3: getPrefix

@Override
public String getPrefix(String uri) {
	if (defaultNamespaceURI != null && defaultNamespaceURI.equals(uri)) {
		return XMLConstants.DEFAULT_NS_PREFIX;
	} else if (uri == null) {
		throw new IllegalArgumentException("Null not allowed as prefix");
	} else if (uri.equals(XMLConstants.XML_NS_URI)) {
		return XMLConstants.XML_NS_PREFIX;
	} else if (uri.equals(XMLConstants.XMLNS_ATTRIBUTE_NS_URI)) {
		return XMLConstants.XMLNS_ATTRIBUTE;
	} else {
		return namespaceIdsMap.get(uri);
	}
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:14,代碼來源:MapBasedNamespaceContext.java

示例4: getSamlObjectQName

@Override
public final QName getSamlObjectQName(final Class objectType) throws RuntimeException {
    try {
        final Field f = objectType.getField(DEFAULT_ELEMENT_LOCAL_NAME_FIELD);
        final String name = f.get(null).toString();

        if (objectType.equals(Response.class) || objectType.equals(Status.class)
                || objectType.equals(StatusCode.class)) {
            return new QName(SAMLConstants.SAML20P_NS, name, "samlp");
        }
        return new QName(SAMLConstants.SAML20_NS, name, XMLConstants.DEFAULT_NS_PREFIX);
    } catch (final Exception e){
        throw new IllegalStateException("Cannot access field " + objectType.getName() + '.' + DEFAULT_ELEMENT_LOCAL_NAME_FIELD);
    }
}
 
開發者ID:hsj-xiaokang,項目名稱:springboot-shiro-cas-mybatis,代碼行數:15,代碼來源:GoogleSaml20ObjectBuilder.java

示例5: getSamlObjectQName

@Override
public QName getSamlObjectQName(final Class objectType) throws RuntimeException {
    try {
        final Field f = objectType.getField(DEFAULT_ELEMENT_LOCAL_NAME_FIELD);
        final String name = f.get(null).toString();

        if (objectType.equals(Response.class) || objectType.equals(Status.class)
                || objectType.equals(StatusCode.class)) {
            return new QName(SAMLConstants.SAML20P_NS, name, "samlp");
        }
        return new QName(SAMLConstants.SAML20_NS, name, XMLConstants.DEFAULT_NS_PREFIX);
    } catch (final Exception e) {
        throw new IllegalStateException("Cannot access field " + objectType.getName() + '.' + DEFAULT_ELEMENT_LOCAL_NAME_FIELD);
    }
}
 
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:15,代碼來源:GoogleSaml20ObjectBuilder.java

示例6: getPrefix

public String getPrefix(String uri) {
    if (fNamespaceContext != null) {
        if (uri == null) {
            uri = XMLConstants.NULL_NS_URI;
        }
        String prefix = fNamespaceContext.getPrefix(uri);
        if (prefix == null) {
            prefix = XMLConstants.DEFAULT_NS_PREFIX;
        }
        return (fSymbolTable != null) ? fSymbolTable.addSymbol(prefix) : prefix.intern();
    }
    return null;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:13,代碼來源:JAXPNamespaceContextWrapper.java

示例7: NodeTest

private QName NodeTest(Context context) throws XPathExpressionException {
    switch (context.tokenAt(1).getType()) {
        case STAR:
            final Token star = context.match(Type.STAR);
            if (Type.COLON == context.tokenAt(1).getType()) {
                context.match(Type.COLON);
                return new QName(star.getToken(), context.match(Type.IDENTIFIER).getToken());
            } else {
                return new QName(star.getToken());
            }
        case IDENTIFIER:
            final Token identifier = context.match(Type.IDENTIFIER);
            if (Type.COLON == context.tokenAt(1).getType()) {
                context.match(Type.COLON);
                final String prefix;
                final String namespaceUri;
                if (null == namespaceContext) {
                    prefix = XMLConstants.DEFAULT_NS_PREFIX;
                    namespaceUri = XMLConstants.NULL_NS_URI;
                } else {
                    prefix = identifier.getToken();
                    namespaceUri = namespaceContext.getNamespaceURI(prefix);
                }
                switch (context.tokenAt(1).getType()) {
                    case STAR:
                        return new QName(namespaceUri, context.match(Type.STAR).getToken(), prefix);
                    case IDENTIFIER:
                        return new QName(namespaceUri, context.match(Type.IDENTIFIER).getToken(), prefix);
                    default:
                }
            } else {
                return new QName(identifier.getToken());
            }
            // fallthrough
        default:
            throw new XPathParserException(context.tokenAt(1), Type.STAR, Type.IDENTIFIER);
    }
}
 
開發者ID:SimY4,項目名稱:xpath-to-xml,代碼行數:38,代碼來源:XPathParser.java

示例8: getPrefix

/**
 * @return the prefix of the current event, or null if the event does not
 * have a prefix. For START_ELEMENT and END_ELEMENT, return
 * XMLConstants.DEFAULT_NS_PREFIX when no prefix is available.
 */
public String getPrefix() {
    if (fEventType == XMLEvent.START_ELEMENT || fEventType == XMLEvent.END_ELEMENT) {
        String prefix = fScanner.getElementQName().prefix;
        return prefix == null ? XMLConstants.DEFAULT_NS_PREFIX : prefix;
    }
    return null;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:12,代碼來源:XMLStreamReaderImpl.java

示例9: NamespaceImpl

/** Creates a new instance of NamespaceImpl */
public NamespaceImpl(String namespaceURI) {
    super(XMLConstants.XMLNS_ATTRIBUTE,XMLConstants.XMLNS_ATTRIBUTE_NS_URI,XMLConstants.DEFAULT_NS_PREFIX,namespaceURI,null);
    init();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:5,代碼來源:NamespaceImpl.java

示例10: writeEmptyElement

public void writeEmptyElement(String prefix, String localName,
    String namespaceURI) throws XMLStreamException {
    try {
        if (localName == null) {
            throw new XMLStreamException("Local Name cannot be null");
        }

        if (namespaceURI == null) {
            throw new XMLStreamException("NamespaceURI cannot be null");
        }

        if (prefix != null) {
            prefix = fSymbolTable.addSymbol(prefix);
        }

        namespaceURI = fSymbolTable.addSymbol(namespaceURI);

        if (fStartTagOpened) {
            closeStartTag();
        }

        openStartTag();

        fElementStack.push(prefix, localName, null, namespaceURI, true);
        fInternalNamespaceContext.pushContext();

        if (!fIsRepairingNamespace) {
            if (prefix == null) {
                throw new XMLStreamException("NamespaceURI " +
                    namespaceURI + " has not been bound to any prefix");
            }
        } else {
            return;
        }

        if ((prefix != null) && (prefix != XMLConstants.DEFAULT_NS_PREFIX)) {
            fWriter.write(prefix);
            fWriter.write(":");
        }

        fWriter.write(localName);
    } catch (IOException e) {
        throw new XMLStreamException(e);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:45,代碼來源:XMLStreamWriterImpl.java

示例11: writeStartElement

/**
 * @param prefix
 * @param localName
 * @param namespaceURI
 * @throws XMLStreamException
 */
@Override
public void writeStartElement(String prefix, String localName,
    String namespaceURI) throws XMLStreamException {
    try {
        if (localName == null) {
            throw new XMLStreamException("Local Name cannot be null");
        }

        if (namespaceURI == null) {
            throw new XMLStreamException("NamespaceURI cannot be null");
        }

        if (!fIsRepairingNamespace) {
            if (prefix == null) {
                throw new XMLStreamException("Prefix cannot be null");
            }
        }

        if (fStartTagOpened) {
            closeStartTag();
        }

        openStartTag();
        namespaceURI = fSymbolTable.addSymbol(namespaceURI);

        if (prefix != null) {
            prefix = fSymbolTable.addSymbol(prefix);
        }

        fElementStack.push(prefix, localName, null, namespaceURI, false);
        fInternalNamespaceContext.pushContext();

        String tmpPrefix = fNamespaceContext.getPrefix(namespaceURI);


        if ((prefix != null) &&
                ((tmpPrefix == null) || !prefix.equals(tmpPrefix))) {
            fInternalNamespaceContext.declarePrefix(prefix, namespaceURI);

        }

        if (fIsRepairingNamespace) {
            if ((prefix == null) ||
                    ((tmpPrefix != null) && prefix.equals(tmpPrefix))) {
                return;
            }

            QName qname = new QName();
            qname.setValues(prefix, XMLConstants.XMLNS_ATTRIBUTE, null,
                namespaceURI);
            fNamespaceDecls.add(qname);

            return;
        }

        if ((prefix != null) && (prefix != XMLConstants.DEFAULT_NS_PREFIX)) {
            fWriter.write(prefix);
            fWriter.write(":");
        }

        fWriter.write(localName);

    } catch (IOException ex) {
        throw new XMLStreamException(ex);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:72,代碼來源:XMLStreamWriterImpl.java

示例12: closeStartTag

/**
 * marks close of start tag and writes the same into the writer.
 */
private void closeStartTag() throws XMLStreamException {
    try {
        ElementState currentElement = fElementStack.peek();

        if (fIsRepairingNamespace) {
            repair();
            correctPrefix(currentElement, XMLStreamConstants.START_ELEMENT);

            if ((currentElement.prefix != null) &&
                    (currentElement.prefix != XMLConstants.DEFAULT_NS_PREFIX)) {
                fWriter.write(currentElement.prefix);
                fWriter.write(":");
            }

            fWriter.write(currentElement.localpart);

            int len = fNamespaceDecls.size();
            QName qname;

            for (int i = 0; i < len; i++) {
                qname = fNamespaceDecls.get(i);

                if (qname != null) {
                    if (fInternalNamespaceContext.declarePrefix(qname.prefix,
                        qname.uri)) {
                        writenamespace(qname.prefix, qname.uri);
                    }
                }
            }

            fNamespaceDecls.clear();

            Attribute attr;

            for (int j = 0; j < fAttributeCache.size(); j++) {
                attr = fAttributeCache.get(j);

                if ((attr.prefix != null) && (attr.uri != null)) {
                    if (!attr.prefix.equals("") && !attr.uri.equals("") ) {
                        String tmp = fInternalNamespaceContext.getPrefix(attr.uri);

                        if ((tmp == null) || (!tmp.equals(attr.prefix))) {
                            tmp = getAttrPrefix(attr.uri);
                            if (tmp == null) {
                                if (fInternalNamespaceContext.declarePrefix(attr.prefix,
                                    attr.uri)) {
                                    writenamespace(attr.prefix, attr.uri);
                                }
                            } else {
                                writenamespace(attr.prefix, attr.uri);
                            }
                        }
                    }
                }

                writeAttributeWithPrefix(attr.prefix, attr.localpart,
                    attr.value);
            }
            fAttrNamespace = null;
            fAttributeCache.clear();
        }

        if (currentElement.isEmpty) {
            fElementStack.pop();
            fInternalNamespaceContext.popContext();
            fWriter.write(CLOSE_EMPTY_ELEMENT);
        } else {
            fWriter.write(CLOSE_START_TAG);
        }

        fStartTagOpened = false;
    } catch (IOException ex) {
        fStartTagOpened = false;
        throw new XMLStreamException(ex);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:79,代碼來源:XMLStreamWriterImpl.java

示例13: QName

/**
 * <p><code>QName</code> constructor specifying the local part.</p>
 *
 * <p>If the local part is <code>null</code> an
 * <code>IllegalArgumentException</code> is thrown.
 * A local part of "" is allowed to preserve
 * compatible behavior with QName 1.0. </p>
 *
 * <p>When using this constructor, the Namespace URI is set to
 * {@link javax.xml.XMLConstants#NULL_NS_URI
 * XMLConstants.NULL_NS_URI} and the prefix is set to {@link
 * javax.xml.XMLConstants#DEFAULT_NS_PREFIX
 * XMLConstants.DEFAULT_NS_PREFIX}.</p>
 *
 * <p><em>In an XML context, all Element and Attribute names exist
 * in the context of a Namespace.  Making this explicit during the
 * construction of a <code>QName</code> helps prevent hard to
 * diagnosis XML validity errors.  The constructors {@link
 * #QName(String namespaceURI, String localPart) QName(String
 * namespaceURI, String localPart)} and
 * {@link #QName(String namespaceURI, String localPart, String prefix)}
 * are preferred.</em></p>
 *
 * <p>The local part is not validated as a
 * <a href="http://www.w3.org/TR/REC-xml-names/#NT-NCName">NCName</a>
 * as specified in <a href="http://www.w3.org/TR/REC-xml-names/">Namespaces
 * in XML</a>.</p>
 *
 * @param localPart local part of the <code>QName</code>
 *
 * @throws IllegalArgumentException When <code>localPart</code> is
 *   <code>null</code>
 *
 * @see #QName(String namespaceURI, String localPart) QName(String
 * namespaceURI, String localPart)
 * @see #QName(String namespaceURI, String localPart, String
 * prefix) QName(String namespaceURI, String localPart, String
 * prefix)
 */
public QName(String localPart) {
    this(
        XMLConstants.NULL_NS_URI,
        localPart,
        XMLConstants.DEFAULT_NS_PREFIX);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:45,代碼來源:QName.java


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