本文整理汇总了Java中org.jaxen.Navigator.getElementNamespaceUri方法的典型用法代码示例。如果您正苦于以下问题:Java Navigator.getElementNamespaceUri方法的具体用法?Java Navigator.getElementNamespaceUri怎么用?Java Navigator.getElementNamespaceUri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jaxen.Navigator
的用法示例。
在下文中一共展示了Navigator.getElementNamespaceUri方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testGetElementNamespaceURIOnAttr
import org.jaxen.Navigator; //导入方法依赖的package包/类
public void testGetElementNamespaceURIOnAttr() {
Navigator nav = getNavigator();
Document doc = builder.newDocument();
Attr a = doc.createAttributeNS("http://www.element.org/", "a");
String qname = nav.getElementNamespaceUri(a);
assertNull(qname);
}
示例2: evaluate
import org.jaxen.Navigator; //导入方法依赖的package包/类
/**
* Returns the namespace URI of <code>list.get(0)</code>
*
* @param list a list of nodes
* @param nav the <code>Navigator</code> used to retrieve the namespace
*
* @return the namespace URI of <code>list.get(0)</code>
*
* @throws FunctionCallException if <code>list.get(0)</code> is not a node
*/
public static String evaluate(List list,
Navigator nav) throws FunctionCallException
{
if ( ! list.isEmpty() )
{
Object first = list.get(0);
if ( first instanceof List )
{
return evaluate( (List) first,
nav );
}
else if ( nav.isElement( first ) )
{
return nav.getElementNamespaceUri( first );
}
else if ( nav.isAttribute( first ) )
{
String uri = nav.getAttributeNamespaceUri( first );
if (uri == null) return "";
return uri;
}
else if ( nav.isProcessingInstruction( first ) )
{
return "";
}
else if ( nav.isNamespace( first ) )
{
return "";
}
else if ( nav.isDocument( first ) )
{
return "";
}
else if ( nav.isComment( first ) )
{
return "";
}
else if ( nav.isText( first ) )
{
return "";
}
else {
throw new FunctionCallException(
"The argument to the namespace-uri function must be a node-set");
}
}
return "";
}
示例3: matches
import org.jaxen.Navigator; //导入方法依赖的package包/类
/**
* Checks whether the node matches this step.
*
* @param node the node to check
* @param contextSupport the context support
* @return true if matches
* @throws JaxenException
*/
public boolean matches(Object node, ContextSupport contextSupport) throws JaxenException {
Navigator nav = contextSupport.getNavigator();
String myUri = null;
String nodeName = null;
String nodeUri = null;
if (nav.isElement(node)) {
nodeName = nav.getElementName(node);
nodeUri = nav.getElementNamespaceUri(node);
}
else if (nav.isText(node)) {
return false;
}
else if (nav.isAttribute(node)) {
if (getAxis() != Axis.ATTRIBUTE) {
return false;
}
nodeName = nav.getAttributeName(node);
nodeUri = nav.getAttributeNamespaceUri(node);
}
else if (nav.isDocument(node)) {
return false;
}
else if (nav.isNamespace(node)) {
if (getAxis() != Axis.NAMESPACE) {
// Only works for namespace::*
return false;
}
nodeName = nav.getNamespacePrefix(node);
}
else {
return false;
}
if (hasPrefix) {
myUri = contextSupport.translateNamespacePrefixToUri(this.prefix);
if (myUri == null) {
throw new UnresolvableException("Cannot resolve namespace prefix '"+this.prefix+"'");
}
}
else if (matchesAnyName) {
return true;
}
// If we map to a non-empty namespace and the node does not
// or vice-versa, fail-fast.
if (hasNamespace(myUri) != hasNamespace(nodeUri)) {
return false;
}
// To fail-fast, we check the equality of
// local-names first. Shorter strings compare
// quicker.
if (matchesAnyName || nodeName.equals(getLocalName())) {
return matchesNamespaceURIs(myUri, nodeUri);
}
return false;
}