当前位置: 首页>>代码示例>>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;未经允许,请勿转载。