當前位置: 首頁>>代碼示例>>Java>>正文


Java Node.detach方法代碼示例

本文整理匯總了Java中org.dom4j.Node.detach方法的典型用法代碼示例。如果您正苦於以下問題:Java Node.detach方法的具體用法?Java Node.detach怎麽用?Java Node.detach使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.dom4j.Node的用法示例。


在下文中一共展示了Node.detach方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: handleRelationField

import org.dom4j.Node; //導入方法依賴的package包/類
private void handleRelationField(String xPathToField, Document xmlDocument)
{
	List nodes = xmlDocument.selectNodes( xPathToField );
	if(nodes != null){
		for(int i = 0; i< nodes.size(); i++){
			Node currentNode = (Node)nodes.get(i);
			String relation = currentNode.getText();
			
			// Insert the URL if an ID is present...
			if(!relation.toLowerCase().matches(".*http\\:\\/\\/.*|.*ftp\\:\\/\\/.*")){
				String relatedID = relation.substring(relation.indexOf(" ")+1,relation.length());
				
				ResultDocList results = 
					index.searchDocs("id:" + SimpleLuceneIndex.encodeToTerm(relatedID));
				if(results == null || results.size() == 0){
					currentNode.detach();
				}else{
					String url = ((ItemDocReader)((ResultDoc)results.get(0)).getDocReader()).getUrl();
					currentNode.setText(relation.substring(0,relation.indexOf(" ") + 1) + url );				
				}				
			}
		}			
	}			
}
 
開發者ID:NCAR,項目名稱:joai-project,代碼行數:25,代碼來源:ADNToOAIDCFormatConverter.java

示例2: replaceNode

import org.dom4j.Node; //導入方法依賴的package包/類
protected static void replaceNode(Node container, Element value) {
	if ( container!=value ) { //not really necessary, I guess...
		Element parent = container.getParent();
		container.detach();
		value.setName( container.getName() );
		value.detach();
		parent.add(value);
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:10,代碼來源:AbstractType.java

示例3: setToXMLNode

import org.dom4j.Node; //導入方法依賴的package包/類
@Override
public void setToXMLNode(Node node, Object value, SessionFactoryImplementor factory)
		throws HibernateException {
	if ( !isEmbeddedInXML ) {
		node.detach();
	}
	else {
		replaceNode( node, (Element) value );
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:11,代碼來源:CollectionType.java

示例4: updateCollectionRecord

import org.dom4j.Node; //導入方法依賴的package包/類
/**
 *  Updates a collection record Document.
 *
 * @param  collectionRecordDoc  A collection record Document (may be from the template)
 * @param  title                Title (must not be null)
 * @param  description          Description (can be null)
 * @param  additionalMetadata   Additional metadata (String, XML, or null)
 * @param  xmlFormat            Format specifier or "DDS_UNCHANGED" to leave unchanged
 * @param  key                  Collection key or "DDS_UNCHANGED" to leave unchanged
 * @param  id                   Record ID or "DDS_UNCHANGED" to leave unchanged
 * @param  accessionDate        Accession date or null to leave unchanged
 * @return                      An updated Document
 * @exception  Exception        If error
 */
private org.dom4j.Document updateCollectionRecord(
                                                  org.dom4j.Document collectionRecordDoc,
                                                  String title,
                                                  String description,
                                                  String additionalMetadata,
                                                  String xmlFormat,
                                                  String key,
                                                  String id,
                                                  Date accessionDate) throws Exception {

	if (!key.equals("DDS_UNCHANGED"))
		collectionRecordDoc.selectSingleNode("/*[local-name()='collectionRecord']/*[local-name()='access']/*[local-name()='key']").setText(key);

	if (!xmlFormat.equals("DDS_UNCHANGED"))
		collectionRecordDoc.selectSingleNode("/*[local-name()='collectionRecord']/*[local-name()='access']/*[local-name()='key']/@libraryFormat").setText(xmlFormat);

	if (!id.equals("DDS_UNCHANGED"))
		collectionRecordDoc.selectSingleNode("/*[local-name()='collectionRecord']/*[local-name()='metaMetadata']/*[local-name()='catalogEntries']/*[local-name()='catalog']/@entry").setText(id);

	if (accessionDate != null)
		collectionRecordDoc.selectSingleNode("/*[local-name()='collectionRecord']/*[local-name()='approval']/*[local-name()='collectionStatuses']/*[local-name()='collectionStatus']/@date").setText(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").format(accessionDate));

	// Update the short title:
	Node shortTitleNode = collectionRecordDoc.selectSingleNode("/*[local-name()='collectionRecord']/*[local-name()='general']/*[local-name()='shortTitle']");
	if (shortTitleNode != null)
		shortTitleNode.setText(title);

	// For previous repositories that are upgraded, remove the fullTitle (legacy)
	Node fullTitleNode = collectionRecordDoc.selectSingleNode("/*[local-name()='collectionRecord']/*[local-name()='general']/*[local-name()='fullTitle']");
	if (fullTitleNode != null)
		fullTitleNode.detach();

	Node descriptionNode = collectionRecordDoc.selectSingleNode("/*[local-name()='collectionRecord']/*[local-name()='general']/*[local-name()='description']");
	if (descriptionNode == null)
		descriptionNode = ((Branch) collectionRecordDoc.selectSingleNode("/*[local-name()='collectionRecord']/*[local-name()='general']")).addElement("description");

	if (description == null || description.trim().length() == 0)
		description = title;
	descriptionNode.setText(description);

	// Delete and then re-create the additionalMetadata node:
	Node additionalMetadataNode = collectionRecordDoc.selectSingleNode("/*[local-name()='collectionRecord']/*[local-name()='additionalMetadata']");
	if (additionalMetadataNode != null)
		additionalMetadataNode.detach();

	if (additionalMetadata != null && additionalMetadata.trim().length() > 0) {
		org.dom4j.Document additionalMetadataDocument;
		try {
			additionalMetadataDocument = Dom4jUtils.getXmlDocument("<additionalMetadata>" + additionalMetadata + "</additionalMetadata>");
		} catch (Throwable t) {
			throw new PutCollectionException("Error processing additionalMetadata argument: " + t.getMessage(), PutCollectionException.ERROR_CODE_BAD_ADDITIONAL_METADATA);
		}
		((Branch) collectionRecordDoc.selectSingleNode("/*[local-name()='collectionRecord']")).add(additionalMetadataDocument.getRootElement());
	}

	return collectionRecordDoc;
}
 
開發者ID:NCAR,項目名稱:joai-project,代碼行數:72,代碼來源:RepositoryManager.java


注:本文中的org.dom4j.Node.detach方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。