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


Java XMLConstants.NULL_NS_URI属性代码示例

本文整理汇总了Java中javax.xml.XMLConstants.NULL_NS_URI属性的典型用法代码示例。如果您正苦于以下问题:Java XMLConstants.NULL_NS_URI属性的具体用法?Java XMLConstants.NULL_NS_URI怎么用?Java XMLConstants.NULL_NS_URI使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在javax.xml.XMLConstants的用法示例。


在下文中一共展示了XMLConstants.NULL_NS_URI属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getNamespaceURI

@Override
public String getNamespaceURI(String prefix) {
	if (XMLConstants.DEFAULT_NS_PREFIX.equals(prefix)) {
		if (defaultNamespaceURI == null) {
			return XMLConstants.NULL_NS_URI;
		} else {
			return defaultNamespaceURI;
		}
	} else if (XMLConstants.XML_NS_PREFIX.equals(prefix)) {
		return XMLConstants.XML_NS_URI;
	} else if (XMLConstants.XMLNS_ATTRIBUTE.equals(prefix)) {
		return XMLConstants.XMLNS_ATTRIBUTE_NS_URI;
	} else if (prefix == null) {
		throw new IllegalArgumentException("Null prefix not allowed");
	} else {
		String uri = idNamespacesMap.get(prefix);
		if (uri == null) {
			return XMLConstants.NULL_NS_URI;
		} else {
			return uri;
		}
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:23,代码来源:MapBasedNamespaceContext.java

示例2: DefaultNamespaceContextProvider

/**
* This constructor uses the <b>node</b> parameter to reach the root element
* of the document, assuming that there will be all namespace declarations.
* @param node The context node for performing XPath operations.
*/
public DefaultNamespaceContextProvider(Node node) {
	if (node.getNodeType()==Node.DOCUMENT_NODE)
		_rootElement=node.getFirstChild();
	else {
		_rootElement=node.getOwnerDocument().getFirstChild();
		while(_rootElement.getNodeType()!=Node.ELEMENT_NODE) {
			_rootElement=_rootElement.getNextSibling();
			if (_rootElement==null)
				break;
		}
	}

	if (_rootElement.getPrefix()!=null)
		_defaultNamespaceURI=_rootElement.getNamespaceURI();
	else {
		_defaultNamespaceURI=XmlHelper.GetNodeAttribute(_rootElement,"xmlns");
		if (StringUtil.isEmptyOrOnlyWhitespaces(_defaultNamespaceURI))
			_defaultNamespaceURI=_rootElement.getNamespaceURI();
		if (StringUtil.isEmptyOrOnlyWhitespaces(_defaultNamespaceURI))
			_defaultNamespaceURI=XMLConstants.NULL_NS_URI;
	}
}
 
开发者ID:costea7,项目名称:ChronoBike,代码行数:27,代码来源:DefaultNamespaceContextProvider.java

示例3: getNamespaceURI

@Override
public String getNamespaceURI(String prefix) {
    if (null == prefix) {
        throw new IllegalArgumentException("prefix");
    } else if (XMLConstants.XMLNS_ATTRIBUTE.equals(prefix)) {
        return XMLConstants.XMLNS_ATTRIBUTE_NS_URI;
    } else if (XMLConstants.XML_NS_PREFIX.equals(prefix)) {
        return XMLConstants.XML_NS_URI;
    } else if ("my".equals(prefix)) {
        return "http://www.example.com/my";
    } else {
        return XMLConstants.NULL_NS_URI;
    }
}
 
开发者ID:SimY4,项目名称:xpath-to-xml,代码行数:14,代码来源:SimpleNamespaceContext.java

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

示例5: getNamespaceURI

@Override
public String getNamespaceURI(String prefix) {
    if (prefix != null) {
        if (prefix.equals(mAndroidPrefix)) {
            return SdkConstants.NS_RESOURCES;
        }
    }

    return XMLConstants.NULL_NS_URI;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:10,代码来源:AndroidXPathFactory.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:SunburstApps,项目名称:OpenJSharp,代码行数:13,代码来源:JAXPNamespaceContextWrapper.java

示例7: getNamespaceURI

/**
 * Returns the namespace corresponding to the specified prefix.
 */
	public String getNamespaceURI( String prefix) {
		String namespaceURI;
//..................... If the default namespace is requested ......................
		if (prefix.equals("") || prefix.equals("def"))
			return _defaultNamespaceURI;

//........................ If any other namespace is requested .....................
		namespaceURI=XmlHelper.GetNodeAttribute(_rootElement,"xmlns:"+prefix);
		if (namespaceURI.length()>0)
			return namespaceURI;

//................... If the requested namespace has not been found ................
		return XMLConstants.NULL_NS_URI;
	}
 
开发者ID:costea7,项目名称:ChronoBike,代码行数:17,代码来源:DefaultNamespaceContextProvider.java

示例8: QName

/**
 * <p><code>QName</code> constructor specifying the Namespace URI,
 * local part and prefix.</p>
 *
 * <p>If the Namespace URI is <code>null</code>, it is set to
 * {@link javax.xml.XMLConstants#NULL_NS_URI
 * XMLConstants.NULL_NS_URI}.  This value represents no
 * explicitly defined Namespace as defined by the <a
 * href="http://www.w3.org/TR/REC-xml-names/#ns-qualnames">Namespaces
 * in XML</a> specification.  This action preserves compatible
 * behavior with QName 1.0.  Explicitly providing the {@link
 * javax.xml.XMLConstants#NULL_NS_URI
 * XMLConstants.NULL_NS_URI} value is the preferred coding
 * style.</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>If the prefix is <code>null</code>, an
 * <code>IllegalArgumentException</code> is thrown.  Use {@link
 * javax.xml.XMLConstants#DEFAULT_NS_PREFIX
 * XMLConstants.DEFAULT_NS_PREFIX} to explicitly indicate that no
 * prefix is present or the prefix is not relevant.</p>
 *
 * <p>The Namespace URI is not validated as a
 * <a href="http://www.ietf.org/rfc/rfc2396.txt">URI reference</a>.
 * The local part and prefix are 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 namespaceURI Namespace URI of the <code>QName</code>
 * @param localPart    local part of the <code>QName</code>
 * @param prefix       prefix of the <code>QName</code>
 *
 * @throws IllegalArgumentException When <code>localPart</code>
 *   or <code>prefix</code> is <code>null</code>
 */
public QName(String namespaceURI, String localPart, String prefix) {
 
    // map null Namespace URI to default
    // to preserve compatibility with QName 1.0
    if (namespaceURI == null) {
        this.namespaceURI = XMLConstants.NULL_NS_URI;
    } else {
        this.namespaceURI = namespaceURI;
    }
 
    // local part is required.
    // "" is allowed to preserve compatibility with QName 1.0
    if (localPart == null) {
        throw new IllegalArgumentException(
                "local part cannot be \"null\" when creating a QName");
    }
    this.localPart = localPart;
 
    // prefix is required
    if (prefix == null) {
        throw new IllegalArgumentException(
                "prefix cannot be \"null\" when creating a QName");
    }
    this.prefix = prefix;
}
 
开发者ID:starn,项目名称:encdroidMC,代码行数:65,代码来源:QName.java

示例9: QName

/**
 * <p><code>QName</code> constructor specifying the Namespace URI,
 * local part and prefix.</p>
 *
 * <p>If the Namespace URI is <code>null</code>, it is set to
 * {@link javax.xml.XMLConstants#NULL_NS_URI
 * XMLConstants.NULL_NS_URI}.  This value represents no
 * explicitly defined Namespace as defined by the <a
 * href="http://www.w3.org/TR/REC-xml-names/#ns-qualnames">Namespaces
 * in XML</a> specification.  This action preserves compatible
 * behavior with QName 1.0.  Explicitly providing the {@link
 * javax.xml.XMLConstants#NULL_NS_URI
 * XMLConstants.NULL_NS_URI} value is the preferred coding
 * style.</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>If the prefix is <code>null</code>, an
 * <code>IllegalArgumentException</code> is thrown.  Use {@link
 * javax.xml.XMLConstants#DEFAULT_NS_PREFIX
 * XMLConstants.DEFAULT_NS_PREFIX} to explicitly indicate that no
 * prefix is present or the prefix is not relevant.</p>
 *
 * <p>The Namespace URI is not validated as a
 * <a href="http://www.ietf.org/rfc/rfc2396.txt">URI reference</a>.
 * The local part and prefix are 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 namespaceURI Namespace URI of the <code>QName</code>
 * @param localPart    local part of the <code>QName</code>
 * @param prefix       prefix of the <code>QName</code>
 *
 * @throws IllegalArgumentException When <code>localPart</code>
 *   or <code>prefix</code> is <code>null</code>
 */
public QName(String namespaceURI, String localPart, String prefix) {

    // map null Namespace URI to default
    // to preserve compatibility with QName 1.0
    if (namespaceURI == null) {
        this.namespaceURI = XMLConstants.NULL_NS_URI;
    } else {
        this.namespaceURI = namespaceURI;
    }

    // local part is required.
    // "" is allowed to preserve compatibility with QName 1.0
    if (localPart == null) {
        throw new IllegalArgumentException(
                "local part cannot be \"null\" when creating a QName");
    }
    this.localPart = localPart;

    // prefix is required
    if (prefix == null) {
        throw new IllegalArgumentException(
                "prefix cannot be \"null\" when creating a QName");
    }
    this.prefix = prefix;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:65,代码来源:QName.java


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