本文整理汇总了Java中org.dom4j.dom.DOMDocument类的典型用法代码示例。如果您正苦于以下问题:Java DOMDocument类的具体用法?Java DOMDocument怎么用?Java DOMDocument使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DOMDocument类属于org.dom4j.dom包,在下文中一共展示了DOMDocument类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: messageSetup
import org.dom4j.dom.DOMDocument; //导入依赖的package包/类
public static Document messageSetup(String rootElement,String namespace,String schemaURL, String actionName, Element content) {
Namespace nmsp=DOMNamespace.get("xsi",namespace);
Document newDoc=new DOMDocument();
Element resp=new DOMElement(rootElement);
Element action=new DOMElement("action");
action.addAttribute("name",actionName);
action.add(content);
resp.addAttribute("xsi:noNamespaceSchemaLocation",schemaURL);
resp.add(nmsp);
resp.add(action);
newDoc.setRootElement(resp);
return newDoc;
}
开发者ID:unsftn,项目名称:bisis-v4,代码行数:16,代码来源:MessageUtil.java
示例2: SimpleXml
import org.dom4j.dom.DOMDocument; //导入依赖的package包/类
/** Create a new SimpleXml just containing the root element.
*
* @param rootElement Name of the root element
*/
public SimpleXml(String rootElement) {
ArgumentNotValid.checkNotNullOrEmpty(rootElement, "String rootElement");
xmlDoc = new DOMDocument();
xmlDoc.addElement(rootElement);
source = "Newly creating XML file with root '" + rootElement + "'";
}
开发者ID:netarchivesuite,项目名称:netarchivesuite-svngit-migration,代码行数:11,代码来源:SimpleXml.java
示例3: testMisc
import org.dom4j.dom.DOMDocument; //导入依赖的package包/类
@Test
public void testMisc ()
{
final Document aXML = new DOMDocument ();
final Element aRoot = aXML.createElement ("rootElement");
assertNotNull (XMLWriter.getNodeAsString (aRoot));
}
开发者ID:phax,项目名称:ph-commons,代码行数:8,代码来源:DOM4JFuncTest.java
示例4: testMisc2
import org.dom4j.dom.DOMDocument; //导入依赖的package包/类
@Test
public void testMisc2 ()
{
final DOMDocument aXML = new DOMDocument ();
final Node aChild = aXML.appendChild (new DOMElement ("rootElement",
new DOMNamespace ("xyz", "http://www.example.org")));
aChild.appendChild (new DOMText ("anyText"));
aChild.appendChild (new DOMEntityReference ("abc"));
assertNotNull (XMLWriter.getNodeAsString (aXML));
}
开发者ID:phax,项目名称:ph-commons,代码行数:12,代码来源:DOM4JFuncTest.java
示例5: toXml
import org.dom4j.dom.DOMDocument; //导入依赖的package包/类
public Document toXml(XmlWriterContext writerContext) {
DOMElement root = new DOMElement("stage");
root.addAttribute("name", stage.getName()).addAttribute("counter", String.valueOf(stage.getCounter()));
Document document = new DOMDocument(root);
root.addElement("link").addAttribute("rel", "self").addAttribute("href", httpUrl(writerContext.getBaseUrl()));
StageIdentifier stageId = stage.getIdentifier();
root.addElement("id").addCDATA(stageId.asURN());
String pipelineName = stageId.getPipelineName();
root.addElement("pipeline").addAttribute("name", pipelineName)
.addAttribute("counter", String.valueOf(stageId.getPipelineCounter()))
.addAttribute("label", stageId.getPipelineLabel())
.addAttribute("href", writerContext.getBaseUrl() + "/api/pipelines/" + pipelineName + "/" + stage.getPipelineId() + ".xml");
root.addElement("updated").addText(DateUtils.formatISO8601(stage.latestTransitionDate()));
root.addElement("result").addText(stage.getResult().toString());
root.addElement("state").addText(stage.status());
root.addElement("approvedBy").addCDATA(stage.getApprovedBy());
Element jobs = root.addElement("jobs");
for (JobInstance jobInstance : stage.getJobInstances()) {
jobs.addElement("job").addAttribute("href", writerContext.getBaseUrl() + "/api/jobs/" + jobInstance.getId() + ".xml");
}
return document;
}
开发者ID:gocd,项目名称:gocd,代码行数:30,代码来源:StageXmlViewModel.java
示例6: toXml
import org.dom4j.dom.DOMDocument; //导入依赖的package包/类
public Document toXml(XmlWriterContext writerContext) throws DocumentException, IOException {
DOMElement root = new DOMElement("pipeline");
root.addAttribute("name", pipeline.getName()).addAttribute("counter", String.valueOf(pipeline.getCounter())).addAttribute("label", pipeline.getLabel());
Document document = new DOMDocument(root);
String baseUrl = writerContext.getBaseUrl();
root.addElement("link").addAttribute("rel", "self").addAttribute("href", httpUrl(baseUrl));
root.addElement("id").addCDATA(pipeline.getPipelineIdentifier().asURN());
PipelineTimelineEntry pipelineAfter = pipeline.getPipelineAfter();
if (pipelineAfter != null) {
addTimelineLink(root, baseUrl, "insertedBefore", pipelineAfter);
}
PipelineTimelineEntry pipelineBefore = pipeline.getPipelineBefore();
if (pipelineBefore != null) {
addTimelineLink(root, baseUrl, "insertedAfter", pipelineBefore);
}
root.addElement("scheduleTime").addText(DateUtils.formatISO8601(pipeline.getScheduledDate()));
Element materials = root.addElement("materials");
for (MaterialRevision materialRevision : pipeline.getCurrentRevisions()) {
populateXml(materials, materialRevision, writerContext);
}
Element stages = root.addElement("stages");
for (StageInstanceModel stage : pipeline.getStageHistory()) {
if (! (stage instanceof NullStageHistoryItem)) {
stages.addElement("stage").addAttribute("href", StageXmlViewModel.httpUrlFor(writerContext.getBaseUrl(), stage.getId()));
}
}
root.addElement("approvedBy").addCDATA(pipeline.getApprovedBy());
return document;
}
开发者ID:gocd,项目名称:gocd,代码行数:37,代码来源:PipelineXmlViewModel.java
示例7: toXml
import org.dom4j.dom.DOMDocument; //导入依赖的package包/类
public Document toXml(XmlWriterContext writerContext) throws DocumentException, IOException {
DOMElement root = new DOMElement("scheduledJobs");
for (WaitingJobPlan jobPlan : jobPlans) {
DOMElement jobElement = getXmlForJobPlan(writerContext, jobPlan);
root.add(jobElement);
}
DOMDocument domDocument = new DOMDocument(root);
return domDocument;
}
开发者ID:gocd,项目名称:gocd,代码行数:10,代码来源:JobPlanXmlViewModel.java
示例8: toXml
import org.dom4j.dom.DOMDocument; //导入依赖的package包/类
public Document toXml(XmlWriterContext writerContext) throws DocumentException, IOException {
DOMElement root = new DOMElement("job");
root.addAttribute("name", jobInstance.getName());
Document document = new DOMDocument(root);
root.addElement("link").addAttribute("rel", "self").addAttribute("href", httpUrl(writerContext.getBaseUrl()));
JobIdentifier identifier = jobInstance.getIdentifier();
root.addElement("id").addCDATA(identifier.asURN());
String pipelineName = identifier.getPipelineName();
StageIdentifier stageId = identifier.getStageIdentifier();
root.addElement("pipeline").addAttribute("name", pipelineName)
.addAttribute("counter", String.valueOf(stageId.getPipelineCounter()))
.addAttribute("label", stageId.getPipelineLabel());
root.addElement("stage").addAttribute("name", stageId.getStageName()).addAttribute("counter", stageId.getStageCounter()).addAttribute("href", StageXmlViewModel.httpUrlFor(
writerContext.getBaseUrl(),
jobInstance.getStageId()));
root.addElement("result").addText(jobInstance.getResult().toString());
root.addElement("state").addText(jobInstance.getState().toString());
Element properties = root.addElement("properties");
for (Property property : writerContext.propertiesForJob(jobInstance.getId())) {
properties.addElement("property").addAttribute("name", property.getKey()).addCDATA(property.getValue());
}
root.addElement("agent").addAttribute("uuid", jobInstance.getAgentUuid());
root.addComment("artifacts of type `file` will not be shown. See https://github.com/gocd/gocd/pull/2875");
Element artifacts = root.addElement("artifacts");
artifacts.addAttribute("baseUri", writerContext.artifactBaseUrl(identifier)).addAttribute("pathFromArtifactRoot", writerContext.artifactRootPath(identifier));
JobPlan jobPlan = writerContext.planFor(identifier);
for (ArtifactPlan artifactPlan : jobPlan.getArtifactPlansOfType(ArtifactType.unit)) {
artifacts.addElement("artifact").addAttribute("src", artifactPlan.getSrc()).addAttribute("dest", artifactPlan.getDest()).addAttribute("type", artifactPlan.getArtifactType().toString());
}
// Retain the top level elements for backward-compatibility
root.addComment("resources are now intentionally left blank. See https://github.com/gocd/gocd/pull/2875");
root.addElement("resources");
root.addComment("environmentvariables are now intentionally left blank. See https://github.com/gocd/gocd/pull/2875");
root.addElement("environmentvariables");
return document;
}
开发者ID:gocd,项目名称:gocd,代码行数:49,代码来源:JobXmlViewModel.java
示例9: save
import org.dom4j.dom.DOMDocument; //导入依赖的package包/类
public static void save(Furnace furnace) throws IOException
{
Document doc = new DOMDocument(new DOMElement(HELP));
Iterable<ConfigurationOption> windupOptions = WindupConfiguration.getWindupConfigurationOptions(furnace);
for (ConfigurationOption option : windupOptions)
{
Element optionElement = new DOMElement(OPTION);
optionElement.addAttribute(NAME, option.getName());
Element descriptionElement = new DOMElement(DESCRIPTION);
descriptionElement.setText(option.getDescription());
optionElement.add(descriptionElement);
// Type
Element typeElement = new DOMElement(TYPE);
typeElement.setText(option.getType().getSimpleName());
optionElement.add(typeElement);
// UI Type
Element uiTypeElement = new DOMElement(UI_TYPE);
uiTypeElement.setText(option.getUIType().name());
optionElement.add(uiTypeElement);
// Available Options
Element availableOptionsElement = new DOMElement(AVAILABLE_OPTIONS);
for (Object availableValueObject : option.getAvailableValues())
{
if (availableValueObject == null)
continue;
Element availableOption = new DOMElement(AVAILABLE_OPTION);
availableOption.setText(String.valueOf(availableValueObject));
availableOptionsElement.add(availableOption);
}
if (!availableOptionsElement.elements().isEmpty())
optionElement.add(availableOptionsElement);
// Is it required?
Element required = new DOMElement(REQUIRED);
required.setText(Boolean.toString(option.isRequired()));
optionElement.add(required);
doc.getRootElement().add(optionElement);
}
try (FileWriter writer = new FileWriter(getDefaultFile()))
{
doc.write(writer);
}
}
开发者ID:windup,项目名称:windup,代码行数:51,代码来源:Help.java
注:本文中的org.dom4j.dom.DOMDocument类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论