本文整理匯總了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;
}
}
}
示例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;
}
}
示例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;
}
}
示例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);
}
}
示例5: getNamespaceURI
@Override
public String getNamespaceURI(String prefix) {
if (prefix != null) {
if (prefix.equals(mAndroidPrefix)) {
return SdkConstants.NS_RESOURCES;
}
}
return XMLConstants.NULL_NS_URI;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}