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


Java XPath.setNamespaceURIs方法代码示例

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


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

示例1: getRecordCount

import org.dom4j.XPath; //导入方法依赖的package包/类
public int getRecordCount () 
{				
    Map<String,String> uris = new HashMap<String,String>();
    uris.put( "ddsws", "http://www.dlese.org/Metadata/ddsws" );
    uris.put( "groups", "http://www.dlese.org/Metadata/groups/" );
    uris.put( "adn", "http://adn.dlese.org" );
    uris.put( "annotation", "http://www.dlese.org/Metadata/annotation" );
    
    XPath xpath = DocumentHelper.createXPath( "//ddsws:results/ddsws:record" );

    xpath.setNamespaceURIs( uris );
    
	List recordNodes = xpath.selectNodes(this.document);
    
    return recordNodes.size();		
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:17,代码来源:CollectionImporter.java

示例2: getXmlUser

import org.dom4j.XPath; //导入方法依赖的package包/类
public void getXmlUser(Document doc, Map<String, String> userColumn) {
	// 根据xpath方式得到所要得到xml文档的具体对象,根据分析解析xml文档可知,xml文档中含有前缀名
	Map<String, String> map = new HashMap<String, String>();
	map.put("c", "collection");
	// 根据xml文档,//c:Table 即为得到的文档对象
	XPath path = doc.createXPath("//c:Users");
	path.setNamespaceURIs(map);
	List<Element> list = path.selectNodes(doc);
	// 得到tables对象,该对象是该pdm文件中所有表的集合
	for (Element element : list) {
		for (Iterator<Element> iter = element.elementIterator("User"); iter
				.hasNext();) {
			Element userElement = iter.next();
			Attribute attribute = userElement.attribute("Id");
			userColumn.put(attribute.getText(),
					userElement.elementText("Code"));
			// setUserlist(userElement.elementText("Code"));
		}
	}
}
 
开发者ID:asiainfo,项目名称:dbcompare,代码行数:21,代码来源:GetTablefmPdm.java

示例3: isMysql

import org.dom4j.XPath; //导入方法依赖的package包/类
public boolean isMysql(Document doc) {
	// 根据xpath方式得到所要得到xml文档的具体对象,根据分析解析xml文档可知,xml文档中含有前缀名
	Map<String, String> map = new HashMap<String, String>();
	map.put("c", "collection");
	// 根据xml文档,//c:Table 即为得到的文档对象
	XPath path = doc.createXPath("//c:DBMS");
	path.setNamespaceURIs(map);
	List<Element> list = path.selectNodes(doc);
	// 得到tables对象,该对象是该pdm文件中所有表的集合
	for (Element element : list) {
		for (Iterator<Element> iter = element.elementIterator("Shortcut"); iter
				.hasNext();) {
			Element userElement = iter.next();
			String s = userElement.elementText("Code").toUpperCase();
			if (s.substring(0, 5).equals("MYSQL")) {
				logger.debug(s);
				return true;
			} else if (s.substring(0, 6).equals("ORACLE")) {
				logger.debug(s);
				return false;
			}

		}
	}
	return false;
}
 
开发者ID:asiainfo,项目名称:dbcompare,代码行数:27,代码来源:GetTablefmPdm.java

示例4: getAttributeValue

import org.dom4j.XPath; //导入方法依赖的package包/类
/**
 * Extracts the value of the supplied attribute
 * 
 * @param element
 *            element with attribute in question
 * @param attributeName
 *            name of the attribute in question
 * @param failIfNotFound
 *            determines if exception should be thrown if attribute is not
 *            found
 * @return value of the attribute in question, null if not found and
 *         failIfNotFound is set to false
 * @throws GenericArtifactParsingException
 *             exception thrown is attribute is missing and failIfNotFound
 *             is set to true
 */
public static String getAttributeValue(Element element,
        String attributeName, boolean failIfNotFound)
        throws GenericArtifactParsingException {
    XPath xpath = new DefaultXPath("@" + attributeName);
    xpath.setNamespaceURIs(ccfNamespaceMap);
    Node attributeNode = xpath.selectSingleNode(element);
    if (attributeNode == null) {
        if (failIfNotFound) {
            throw new GenericArtifactParsingException("Missing attribute: "
                    + attributeName + " in element " + element.getName());
        } else {
            return null;
        }
    } else {
        return attributeNode.getText();
    }
}
 
开发者ID:jonico,项目名称:core,代码行数:34,代码来源:XPathUtils.java

示例5: applyXPath

import org.dom4j.XPath; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private boolean applyXPath()
{
 try{
     XPath xpath = data.document.createXPath(data.PathValue);
     if(meta.isNamespaceAware())
     {
  	   xpath = data.document.createXPath(addNSPrefix(data.PathValue,	data.PathValue));
  	   xpath.setNamespaceURIs(data.NAMESPACE);
     }
     // get nodes list
  data.an =  (List<AbstractNode>) xpath.selectNodes(data.document);
  data.nodesize=data.an.size();
  data.nodenr=0;
 }catch (Exception e)
 {
  logError(BaseMessages.getString(PKG, "GetXMLData.Log.ErrorApplyXPath",e.getMessage()));
  return false;
 }
 return true;
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:22,代码来源:GetXMLData.java

示例6: getXPath

import org.dom4j.XPath; //导入方法依赖的package包/类
/** Get an XPath version of the given dotted path.  A dotted path
 * foo.bar.baz corresponds to the XML node &lt;foo&gt;&lt;bar&gt;&lt;baz&gt;
 *  &lt;/baz&gt;&lt;/bar&gt;&lt;/foo&gt;
 *
 * Implementation note: If needed, this could be optimized by keeping a
 * HashMap cache of the XPaths, since they don't change.
 *
 * @param path A dotted path
 * @return An XPath that matches the dotted path equivalent, using
 * "dk:" as namespace prefix for all but the first element.
 */
private XPath getXPath(String path) {
    String[] pathParts = path.split("\\.");
    StringBuilder result = new StringBuilder();
    result.append("/");
    result.append(pathParts[0]);
    for (int i = 1; i < pathParts.length; i++) {
        result.append("/dk:");
        result.append(pathParts[i]);
    }
    XPath xpath = xmlDoc.createXPath(result.toString());
    Namespace nameSpace = xmlDoc.getRootElement().getNamespace();
    Map<String, String> namespaceURIs = new HashMap<String, String>(1);
    namespaceURIs.put("dk", nameSpace.getURI());
    xpath.setNamespaceURIs(namespaceURIs);
    return xpath;
}
 
开发者ID:netarchivesuite,项目名称:netarchivesuite-svngit-migration,代码行数:28,代码来源:SimpleXml.java

示例7: applyXPath

import org.dom4j.XPath; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private boolean applyXPath()
{
 try{
     XPath xpath = data.document.createXPath(data.PathValue);
     if(meta.isNamespaceAware())
     {
  	   xpath = data.document.createXPath(addNSPrefix(data.PathValue,	data.PathValue));
  	   xpath.setNamespaceURIs(data.NAMESPACE);
     }
     // get nodes list
  data.an =  (List<AbstractNode>) xpath.selectNodes(data.document);
  data.nodesize=data.an.size();
  data.nodenr=0;
 }catch (Exception e)
 {
  log.logError(toString(),Messages.getString("GetXMLData.Log.ErrorApplyXPath",e.getMessage()));
  return false;
 }
 return true;
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:22,代码来源:GetXMLData.java

示例8: applyXPath

import org.dom4j.XPath; //导入方法依赖的package包/类
@SuppressWarnings( "unchecked" )
private boolean applyXPath() {
  try {
    XPath xpath = data.document.createXPath( data.PathValue );
    if ( meta.isNamespaceAware() ) {
      xpath = data.document.createXPath( addNSPrefix( data.PathValue, data.PathValue ) );
      xpath.setNamespaceURIs( data.NAMESPACE );
    }
    // get nodes list
    data.an = xpath.selectNodes( data.document );
    data.nodesize = data.an.size();
    data.nodenr = 0;
  } catch ( Exception e ) {
    logError( BaseMessages.getString( PKG, "GetXMLData.Log.ErrorApplyXPath", e.getMessage() ) );
    return false;
  }
  return true;
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:19,代码来源:GetXMLData.java

示例9: getCollectionKeyFromDDS

import org.dom4j.XPath; //导入方法依赖的package包/类
public String getCollectionKeyFromDDS( String _collectionName )
{
	String collectionKey = null;

	// make the call to DDS and get ListCollections 
	try { 
		URLConnection connection = new URL ("http://www.dlese.org/dds/services/ddsws1-1?verb=ListCollections" ).openConnection();			
        connection.setDoOutput( true );
        connection.setDoInput(true);
        
        ((HttpURLConnection)connection).setRequestMethod("GET");
        
        Map<String,String> uris = new HashMap<String,String>();
	    uris.put( "ddsws", "http://www.dlese.org/Metadata/ddsws" );	       
        uris.put( "ddswsnews", "http://www.dlese.org/Metadata/ddswsnews" );
	    uris.put( "groups", "http://www.dlese.org/Metadata/groups/" );
	    uris.put( "adn", "http://adn.dlese.org" );
	    uris.put( "annotation", "http://www.dlese.org/Metadata/annotation" );
	    
	    XPath xpath = DocumentHelper.createXPath( "//collections/collection[vocabEntry=\"" + _collectionName + "\"]/searchKey/text()" );

	    xpath.setNamespaceURIs( uris );
	    
	    SAXReader xmlReader = new SAXReader();
	    
	    this.document = xmlReader.read(connection.getInputStream());	
	            
	    Text t = ((Text)xpath.selectSingleNode(this.document));
	    
		collectionKey = t.getStringValue();
		
	} catch ( Exception e ) {
		e.printStackTrace();
	}
	
	return collectionKey;
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:38,代码来源:CollectionImporter.java

示例10: getValue

import org.dom4j.XPath; //导入方法依赖的package包/类
private String getValue(String xpath) {
	XPath xpathObj = DocumentHelper.createXPath(xpath);
	xpathObj.setNamespaceURIs(getNSMap());
	Node node = xpathObj.selectSingleNode(doc);
	if (node != null)
		return node.getText();
	else
		return null;
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:10,代码来源:ServiceDescriptionReader.java

示例11: getValue

import org.dom4j.XPath; //导入方法依赖的package包/类
private String getValue (String xpath) {
	XPath xpathObj = DocumentHelper.createXPath(xpath);
	xpathObj.setNamespaceURIs(getNSMap());
	Node node = xpathObj.selectSingleNode(doc);
	if (node != null)
		return node.getText();
	else
		return null;
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:10,代码来源:NsdlDcReader.java

示例12: getValues

import org.dom4j.XPath; //导入方法依赖的package包/类
private List getValues(String xpath) {
	XPath xpathObj = DocumentHelper.createXPath(xpath);
	xpathObj.setNamespaceURIs(getNSMap());
	List nodes = xpathObj.selectNodes(doc);
	List values = new ArrayList();
	for (Iterator i = nodes.iterator(); i.hasNext(); ) {
		values.add(((Node) i.next()).getText());
	}
	return values;
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:11,代码来源:HarvestInfoReader.java

示例13: createXPath

import org.dom4j.XPath; //导入方法依赖的package包/类
private XPath createXPath( String xpathExpr )
{
    XPath xpath = document.createXPath( xpathExpr );
    if ( !this.namespaceMap.isEmpty() )
    {
        xpath.setNamespaceURIs( this.namespaceMap );
    }
    return xpath;
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:10,代码来源:XMLReader.java

示例14: getAttributeValue

import org.dom4j.XPath; //导入方法依赖的package包/类
/**
 * Extracts the value of the supplied attribute
 * 
 * @param element
 *            element with attribute in question
 * @param attributeName
 *            name of the attribute in question
 * @return value of the attribute in question
 * @throws GenericArtifactParsingException
 *             exception s thrown is attribute is missing
 */
private static String getAttributeValue(Element element,
        String attributeName) throws GenericArtifactParsingException {
    // TODO Cash constructed XPath objects?
    // XPath xpath = new DefaultXPath("@" + CCF_NAMESPACE_PREFIX + ":" +
    // attributeName);
    XPath xpath = new DefaultXPath("@" + attributeName);
    xpath.setNamespaceURIs(ccfNamespaceMap);
    Node attributeNode = xpath.selectSingleNode(element);
    if (attributeNode == null)
        throw new GenericArtifactParsingException("Missing attribute: "
                + attributeName + " in element " + element.getName());
    else
        return attributeNode.getText();
}
 
开发者ID:jonico,项目名称:core,代码行数:26,代码来源:GenericArtifactHelper.java

示例15: getAttributeValueWithoutException

import org.dom4j.XPath; //导入方法依赖的package包/类
/**
 * Extracts the value of the supplied attribute without throwing an
 * exception if missing
 * 
 * @param element
 *            element with attribute in question
 * @param attributeName
 *            name of the attribute in question
 * @return value of the attribute in question, null if attribute is missing
 * 
 */
private static String getAttributeValueWithoutException(Element element,
        String attributeName) {
    // TODO Cash constructed XPath objects?
    // XPath xpath = new DefaultXPath("@" + CCF_NAMESPACE_PREFIX + ":" +
    // attributeName);
    XPath xpath = new DefaultXPath("@" + attributeName);
    xpath.setNamespaceURIs(ccfNamespaceMap);
    Node attributeNode = xpath.selectSingleNode(element);
    if (attributeNode == null)
        return null;
    else
        return attributeNode.getText();
}
 
开发者ID:jonico,项目名称:core,代码行数:25,代码来源:GenericArtifactHelper.java


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