本文整理汇总了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;
}