本文整理匯總了Java中org.dom4j.Element.add方法的典型用法代碼示例。如果您正苦於以下問題:Java Element.add方法的具體用法?Java Element.add怎麽用?Java Element.add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.dom4j.Element
的用法示例。
在下文中一共展示了Element.add方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createEntityFieldsCollectionElement
import org.dom4j.Element; //導入方法依賴的package包/類
protected Element createEntityFieldsCollectionElement(Entity fieldEntity){
Collection<EntityField> entityFields=fieldEntity.getEntityFields();
String entityTableName=fieldEntity.getTableName();
Element collection=new BaseElement("Collection");
for(EntityField ef:entityFields){
if(!entityTableName.equals(ef.getTableName())){
continue;
}
Element entity = new BaseElement("Entity");
entity.add(this.createPropertyElement("name", ef.getName()));
entity.add(this.createPropertyElement("keyGenerator", ef.getKeyGenerator()));
entity.add(this.createPropertyElement("keyGenerateType", ef.getKeyGenerateType().toString()));
entity.add(this.createPropertyElement("submittable", String.valueOf(ef.isSubmittable())));
collection.add(entity);
}
return collection;
}
示例2: flush
import org.dom4j.Element; //導入方法依賴的package包/類
/**
* Update DocMap with recent ActionPath and GuardedPaths, and then write it to
* disk.
*
* @exception Exception NOT YET DOCUMENTED
*/
public synchronized void flush() throws Exception {
Element root = df.createElement(rootElementName);
Document doc = df.createDocument(root);
try {
Element guardedPaths = root.addElement("guarded-paths");
for (Iterator i = guardedPathMap.values().iterator(); i.hasNext(); ) {
GuardedPath gp = (GuardedPath) i.next();
guardedPaths.add(gp.asElement());
}
Element actionpaths = root.addElement("action-paths");
for (Iterator i = actionPathMap.values().iterator(); i.hasNext(); ) {
ActionPath ap = (ActionPath) i.next();
actionpaths.add(ap.asElement());
}
docMap = new DocMap(doc);
} catch (Throwable t) {
prtln("flush error: " + t.getMessage());
t.printStackTrace();
throw new Exception(t.getCause());
}
super.flush();
}
示例3: newItemInput
import org.dom4j.Element; //導入方法依賴的package包/類
Element newItemInput () {
Element acceptsNewSibling = rhelper.acceptsNewSiblingTest(xpath);
String itemPath = siblingPath + "_${" + indexId + "+1}_";
Element id = this.df.createElement ("bean__define")
.addAttribute ("id", indexId)
.addAttribute ("name", this.formBeanName)
.addAttribute ("property", "memberCountOf(" + xpath + ")");
// create fieldElement (containing input element)
Element fieldElement = df.createElement("div");
// new anyType input element
int rows = 8;
Element input = df.createElement("html__textarea")
.addAttribute("property", "anyTypeValueOf(" + itemPath + ")")
.addAttribute("style", "width__98%")
.addAttribute("rows", String.valueOf(rows));
SimpleTypeLabel label = renderer.getSimpleTypeLabel(itemPath);
acceptsNewSibling.add (id);
acceptsNewSibling.add(this.renderer.getRenderedField(itemPath, label, input));
return acceptsNewSibling;
}
示例4: emptyRepeatingElement
import org.dom4j.Element; //導入方法依賴的package包/類
/**
* Render jsp element for adding a new repeating element that will be shown
* when there are no existing values for this field in the instance document.
*
* @return NOT YET DOCUMENTED
*/
protected Element emptyRepeatingElement() {
Element emptyRepeat = rhelper.nodeHasNoMembersTest(xpath);
String nodeName = XPathUtils.getLeaf(xpath);
prtln("emptyRepeatingElement() for " + nodeName);
// build control element
Element controlElement = df.createElement("div");
Element newItemAction = controlElement.addElement("div")
.addAttribute("class", "action-button");
Element newItemLink = newItemAction.addElement("a")
.addAttribute("href", "javascript:doNewElement(" + RendererHelper.jspQuotedString(xpath) + ")");
rhelper.attachToolHelp(newItemLink, "Create a new " + nodeName);
newItemLink.setText("add " + nodeName);
prtln("calling renderer.getSimpleTypeLabel(xpath)");
Label label = renderer.getSimpleTypeLabel(xpath);
if (!this.schemaNode.isRequired())
((SimpleTypeLabel)label).setOptional();
emptyRepeat.add(getRenderedNoInputField(label, controlElement));
return emptyRepeat;
}
示例5: toDsml
import org.dom4j.Element; //導入方法依賴的package包/類
/**
* Converts this Batch Response to its XML representation in the DSMLv2 format.
*
* @param prettyPrint if true, formats the document for pretty printing
* @return the XML representation in DSMLv2 format
*/
public String toDsml( boolean prettyPrint )
{
Document document = DocumentHelper.createDocument();
Element element = document.addElement( "batchResponse" );
element.add( ParserUtils.DSML_NAMESPACE );
element.add( ParserUtils.XSD_NAMESPACE );
element.add( ParserUtils.XSI_NAMESPACE );
// RequestID
if ( requestID != 0 )
{
element.addAttribute( "requestID", Integer.toString( requestID ) );
}
for ( DsmlDecorator<? extends Response> response : responses )
{
response.toDsml( element );
}
if ( prettyPrint )
{
document = ParserUtils.styleDocument( document );
}
return document.asXML();
}
示例6: createDataProvider
import org.dom4j.Element; //導入方法依賴的package包/類
private Element createDataProvider(Entity entity){
Element element=new BaseElement("DataProvider");
element.addAttribute("type", "direct");
String entityName=entity.getName();
element.addAttribute("name", "dataProvider"+entityName.substring(0,1).toUpperCase()+entityName.substring(1,entityName.length()));
element.add(this.createPropertyElement("interceptor", "spring:bdf.rapido.commonPR#loadEntityData"));
Element metaData=this.createPropertyElement("metaData", null);
metaData.add(this.createPropertyElement(Constants.QUERY_SQL, entity.getQuerySql()));
element.add(metaData);
return element;
}
示例7: addSiblingNodeTest
import org.dom4j.Element; //導入方法依賴的package包/類
@Test
public void addSiblingNodeTest() throws IOException, SAXException, TransformerException {
Document doc = DocumentHelper.createDocument(DocumentHelper.createElement("root"));
Element root = doc.getRootElement();
Element child = DocumentHelper.createElement("child");
child.setText("test value 1");
root.add(child);
xmlBuilder.addNode(doc, "/root/child", "test value 2", uris.get("ARCLIB"));
assertThat(doc.asXML(), is("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<root><child>test value 1</child><child xmlns=\"http://arclib.lib.cas.cz/ARCLIB_XML\">test value 2</child></root>"));
}
示例8: untargetedInsert
import org.dom4j.Element; //導入方法依賴的package包/類
/**
* Insert an element in it's parent element using compositor. The compositor
* can provide information that allows us to place the new element at the
* correct place in the parent element.
*
* @param element NOT YET DOCUMENTED
* @param parent NOT YET DOCUMENTED
* @exception Exception NOT YET DOCUMENTED
*/
private void untargetedInsert(Element element, Element parent) throws Exception {
// prtln("\n untargetedInsert()");
// prtln("\telement name: " + element.getQualifiedName());
// prtln ("\telement to insert: " + Dom4jUtils.prettyPrint(element) + "\n");
String parentPath = parent.getPath();
if (schemaHelper == null || !schemaHelper.hasSequenceCompositor(parentPath)) {
// prtln ("no help from schemaHelper - inserting element at end of parent");
if (schemaHelper == null)
prtln("SchemaHelper is NULL");
parent.add(element);
return;
}
else {
Sequence compositor = (Sequence) schemaHelper.getCompositor(parentPath);
String compositorMemberName = resolveElementName(parentPath, element);
int memberIndex = compositor.getIndexOfMember(compositorMemberName);
/*
insert element immediately following other like-named elements, or just ahead
of the following member if no like-named elements exist.
when the childMemberIndex is greater than the (target) memberIndex, then it is
time to insert.
*/
List elements = parent.elements();
for (int i = 0; i < elements.size(); i++) {
Element child = (Element) elements.get(i);
String childCompositorMemberName = resolveElementName(parentPath, child);
int childMemberIndex = compositor.getIndexOfMember(childCompositorMemberName);
if (childMemberIndex > memberIndex) {
elements.add(i, element);
return;
}
}
parent.add(element);
}
}
示例9: orderSequenceElements
import org.dom4j.Element; //導入方法依賴的package包/類
/**
* Put sequence elements in the order specified by the sequence compositor.
*
* @param parent NOT YET DOCUMENTED
*/
public void orderSequenceElements(Element parent) {
String xpath = parent.getPath();
List order = schemaHelper.getChildrenOrder(xpath);
// just as a safeguard, don't reorder if there is only one child
// for the schemaNode, since parent is probably a repeating element
// and reordering would wipe out all but one child
if (order.size() < 2)
return;
// map element name to a list of elements to accomodate repeating elements
Map elementMap = new HashMap();
List elements = parent.elements();
for (int i = elements.size() - 1; i > -1; i--) {
Element e = (Element) elements.get(i);
String tagName = e.getName();
List items = (List) elementMap.get(tagName);
if (items == null)
items = new ArrayList();
items.add(0, e.detach()); // add to beginning to maintain doc ordering
elementMap.put(tagName, items);
}
for (Iterator i = order.iterator(); i.hasNext(); ) {
String name = (String) i.next();
elements = (List) elementMap.get(name);
if (elements != null) {
for (Iterator ii = elements.iterator(); ii.hasNext(); ) {
parent.add((Element) ii.next());
}
}
}
}
示例10: getRepeatingContent
import org.dom4j.Element; //導入方法依賴的package包/類
/**
* Renders the contents of this node, which are in turn rendered inside an iteration element.
*
* @param itemPath the xpath for this element, with indexing to support iteration
* @return The repeatingContent value
*/
protected Element getRepeatingContent(String itemPath) {
// prtln ("getRepeatingContent() with itemPath: " + itemPath);
Element repeatingContent = getRepeatingContentBox (itemPath);
Label label;
if (indexRepeatingContentLabels) {
label = renderer.getComplexTypeLabel(xpath, itemPath, indexId);
}
else {
label = renderer.getComplexTypeLabel(xpath);
}
String elementName = XPathUtils.getNodeName(this.siblingPath);
Element controller = renderer.getDeleteController(itemPath, elementName);
Element inputHelper = this.renderer.getInputHelperElement(this.xpath);
repeatingContent.add(getRenderedNoInputField(label, controller, inputHelper));
Element subElementsBox = repeatingContent.addElement("div");
subElementsBox.addAttribute("id", "${id}");
if (getLevel() > 0 && isEditMode()) {
subElementsBox.addAttribute("style", "display:${"+formBeanName+".collapseBean.displayState};");
/* this.attachElementDebugInfo(subElementsBox, "subElementsBox: id=${id}", "green"); */
}
newRenderer(itemPath, subElementsBox).renderSubElements();
return repeatingContent;
}
示例11: getMultiSelectInput
import org.dom4j.Element; //導入方法依賴的package包/類
/**
* Renders a multiSelect input (a set of of checkboxes) as an Element. The
* multiSelect is represented as a HTML table
*
* @param xpath NOT YET DOCUMENTED
* @return The multiSelectInput as an element
*/
public Element getMultiSelectInput(String xpath) {
// prtln("getMultiSelectInput() with " + xpath);
Element multiSelectTable = df.createElement("table");
if (!this.sh.isSingleton(xpath)) {
// multiSelectTable.addAttribute("info", "multiSelectTable: id=${id}");
String style = "display__${" + formBeanName + ".collapseBean.displayState};";
// style += "border__red thin dotted;";
multiSelectTable.addAttribute("style", style);
}
multiSelectTable.addAttribute("width", "100%");
Element row = multiSelectTable.addElement("tr")
.addAttribute("valign", "top");
Element multiSelectCell = row.addElement("td");
/*
a hidden field is necessary to compensate for the fact that we don't have a reset method in the
form bean. the hidden field points to the subjectsPath without an index modifier on the leaf..
*/
Element hidden = multiSelectCell.addElement("input")
.addAttribute("type", "hidden")
.addAttribute("name", "enumerationValuesOf(" + XPathUtils.getSiblingXPath(xpath) + ")")
.addAttribute("value", "");
multiSelectCell.add(getMultiBoxInput(xpath));
return multiSelectTable;
}
示例12: getSubstitutionGroupNewItemControl
import org.dom4j.Element; //導入方法依賴的package包/類
protected Element getSubstitutionGroupNewItemControl() {
Element newItemAction = df.createElement("div")
.addAttribute("class", "action-button");
//make a drop-down menu with choices, and present as controller
/*
do not present control if there are no children
- this case is handled elsewhere (search for "required choice")
-- but should it be handled here?
*/
Element notEmptyTest = newItemAction.addElement("logic__notEmpty")
.addAttribute("name", formBeanName)
.addAttribute("property", "membersOf(" + xpath + "/*)");
notEmptyTest = newItemAction;
// tests whether the instance document can accept a new child given
// schema constraints
Element canAcceptTest = notEmptyTest.addElement("logic__equal")
.addAttribute("name", formBeanName)
.addAttribute("property", "acceptsNewSubstitionGroupMember(" + xpath + ")")
.addAttribute("value", "true");
String elementId = "${id}_controller";
String Name = XPathUtils.getNodeName(normalizedXPath);
Element newItemPrompt = canAcceptTest.addElement("div");
newItemPrompt.setText("add " + XPathUtils.getNodeName (xpath));
rhelper.attachToolHelp(newItemPrompt, "Choose a field to add from the pulldown menu");
// wrap prompt and select in div
Element selectWrapper = canAcceptTest.addElement ("div");
this.embedDebugInfo(selectWrapper, "MdeRepeatingSubstitutionGroup - selectWrapper");
// tmpArg is initialized to "" so the "-- choice --" option is selected,
// rather than one of the choices
Element tmpArgInit = selectWrapper.addElement("jsp__setProperty")
.addAttribute("name", formBeanName)
.addAttribute("property", "tmpArg")
.addAttribute("value", "");
// the select element for making a choice
Element newItemSelect = selectWrapper.addElement("html__select")
.addAttribute("name", formBeanName)
.addAttribute("property", "tmpArg")
.addAttribute("onchange", "doNewChoice (this.value)");
// the permissible choices for this element
Element newChoiceOptions = newItemSelect.addElement("html__optionsCollection")
.addAttribute("property", "substitutionGroupOptions(" + xpath + ")");
rhelper.attachToolHelp(newItemSelect, "Choose an element to create");
// wrap the newItemAction in a table. the left cell is the controller, and the right is blank
Element table = df.createElement("table")
.addAttribute ("class", "input-field-table");
Element row = table.addElement ("tr")
.addAttribute ("class", "form-row");
Element controllerCell = row.addElement ("td")
.addAttribute ("class", "action-box")
.addAttribute ("nowrap", "1");
controllerCell.add (newItemAction);
Element emptyCell = row.addElement ("td")
.addAttribute ("width", "95%");
emptyCell.setText (" ");
return table;
}
示例13: add
import org.dom4j.Element; //導入方法依賴的package包/類
public void add(Element element) {
element.add( element );
}
示例14: extractIncrement
import org.dom4j.Element; //導入方法依賴的package包/類
/**
* 根據節點數據,生成增量文本xml
*
* @param list 節點數據
* @param buildNew 替換新文本
* @param printAll 是否打印結果
* @return
* @throws Exception
*/
@Override
public Document extractIncrement(List<? extends NodeResult> list, boolean buildNew, boolean print)
throws Exception {
Element root = DocumentHelper.createElement("contentList");
Iterator<?> it = list.iterator();
boolean first100 = true, first80 = true, first50 = true, first25 = true, first15 = true,
first5 = true, first = true;
if (print) {
if (buildNew) {
System.out.println("----------------------------左邊是增量文本,右邊是原文本-----------------");
} else {
System.out.println("----------------------------左邊是原文本,右邊是增量文本-----------------");
}
}
while (it.hasNext()) {
NodeResult nodeResult = (NodeResult) it.next();
Element e = DocumentHelper.createElement("content");
e.addAttribute("contentuid", nodeResult.getContentuid());
e.setText(buildNew ? nodeResult.getNewText() : nodeResult.getText());
if (print) {
if (nodeResult instanceof DiffResult) {
DiffResult res = (DiffResult) nodeResult;
if (first100 && res.getDifference() >= 1.0) {
System.out.println("----------------------------差異超過100%的文本-----------------");
first100 = false;
}
if (first80 && res.getDifference() < 1.0 && res.getDifference() > 0.8) {
System.out.println("\n\n----------------------------差異超過80%的文本-----------------");
first80 = false;
}
if (first50 && res.getDifference() <= 0.8 && res.getDifference() > 0.5) {
System.out.println("\n\n----------------------------差異超過50%的文本-----------------");
first50 = false;
}
if (first25 && res.getDifference() <= 0.5 && res.getDifference() > 0.25) {
System.out.println("\n\n----------------------------差異超過25%的文本-----------------");
first25 = false;
}
if (first15 && res.getDifference() <= 0.25 && res.getDifference() > 0.15) {
System.out.println("\n\n----------------------------差異超過15%的文本-----------------");
first15 = false;
}
if (first5 && res.getDifference() <= 0.15 && res.getDifference() > 0.05) {
System.out.println("\n\n----------------------------差異超過5%的文本-----------------");
first5 = false;
}
if (first && res.getDifference() < 0.05) {
System.out.println("\n\n----------------------------差異低於5%的文本-----------------");
first = false;
}
}
System.out.println(nodeResult.getContentuid() + "="
+ (buildNew ? (nodeResult.getText() + "|" + nodeResult.getNewText())
: (nodeResult.getNewText() + "|" + nodeResult.getText())));
}
root.add(e);
}
Document doc = DocumentHelper.createDocument(root);
return doc;
}
示例15: render
import org.dom4j.Element; //導入方法依賴的package包/類
/**
* Identical to SimpleJspRenderer.renderRepeatingElement, but adds a controller
* for deleting items`
*/
public void render() {
prtln("\nrender() with " + xpath);
// prtln ("mode: " + getMode());
Element repeatingItemsBox = df.createElement("div");
this.embedDebugInfo (repeatingItemsBox, "MdeRepeatingDerivedContentModel - repeatingItemsBox");
Element iteration = null;
// attachElementDebugInfo(repeatingItemsBox, "repeating Derived Model Box (" + xpath + ")", "blue");
if (isEditMode()) {
// we don't want to show anything here if the parent doesn't exist!
Element parentExists = rhelper.parentNodeExistsTest(xpath);
parent.add (parentExists);
parentExists.add (repeatingItemsBox);
if (!sh.isRepeatingComplexSingleton(normalizedXPath)) {
prtln ("\t calling emptyRepeatingElement()");
repeatingItemsBox.add (emptyRepeatingElement());
}
Element hasMemberTest = rhelper.nodeHasMembersTest (xpath);
repeatingItemsBox.add (hasMemberTest);
iteration = getIteration(itemPath, siblingPath, indexId);
insertRepeatingDisplaySetup(iteration);
hasMemberTest.add (iteration);
Element siblingController = newSiblingController();
repeatingItemsBox.add (siblingController);
}
else {
parent.add (repeatingItemsBox);
iteration = getIteration(itemPath, siblingPath, indexId);
repeatingItemsBox.add (iteration);
}
// attach repeatingContent as child of the iteration, so each item is displayed
Element repeatingContent = getRepeatingContent();
if (repeatingContent != null)
iteration.add(repeatingContent);
}