本文整理匯總了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 );
}
}
}
}
}
示例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);
}
}
示例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 );
}
}
示例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;
}