本文整理了Java中org.dom4j.Element.addCDATA()
方法的一些代码示例,展示了Element.addCDATA()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.addCDATA()
方法的具体详情如下:
包路径:org.dom4j.Element
类名称:Element
方法名:addCDATA
[英]Adds a new CDATA
node with the given text to this element.
[中]将具有给定文本的新CDATA
节点添加到此元素。
代码示例来源:origin: spotbugs/spotbugs
@Override
public void writeCDATA(String cdata) {
Element top = (Element) stack.getLast();
top.addCDATA(cdata);
}
代码示例来源:origin: gocd/gocd
@Override
void populateXmlForModifications(Modifications modifications, XmlWriterContext writerContext, Element modificationsTag) {
for (Modification modification : modifications) {
Element changeset = modificationsTag.addElement("changeset");
changeset.addAttribute("changesetUri", ScmMaterial.changesetUrl(modification, writerContext.getBaseUrl(), material.getId()));
changeset.addElement("user").addCDATA(modification.getUserDisplayName());
changeset.addElement("checkinTime").addText(DateUtils.formatISO8601(modification.getModifiedTime()));
changeset.addElement("revision").addCDATA(modification.getRevision());
changeset.addElement("message").addCDATA(modification.getComment());
}
}
}
代码示例来源:origin: igniterealtime/Openfire
childElement.addCDATA(value.substring(9, value.length()-3));
代码示例来源:origin: igniterealtime/Openfire
element.addCDATA(value.substring(9, value.length() - 3));
} else {
String propValue = StringEscapeUtils.escapeXml10(value);
代码示例来源:origin: gocd/gocd
@Override
void populateXmlForModifications(Modifications modifications, XmlWriterContext writerContext, Element modificationsTag) {
for (Modification modification : modifications) {
Element changeset = modificationsTag.addElement("changeset");
changeset.addAttribute("changesetUri", ScmMaterial.changesetUrl(modification, writerContext.getBaseUrl(), material.getId()));
changeset.addElement("user").addCDATA(modification.getUserDisplayName());
changeset.addElement("checkinTime").addText(DateUtils.formatISO8601(modification.getModifiedTime()));
changeset.addElement("revision").addCDATA(modification.getRevision());
changeset.addElement("message").addCDATA(modification.getComment());
List<ModifiedFile> modifiedFiles = modification.getModifiedFiles();
for (ModifiedFile modifiedFile : modifiedFiles) {
changeset.addElement("file").addAttribute("name", modifiedFile.getFileName()).addAttribute("action", modifiedFile.getAction().toString());
}
}
}
}
代码示例来源:origin: spotbugs/spotbugs
private void addBugPatterns(Set<String> bugTypeSet) {
Element root = document.getRootElement();
for (String bugType : bugTypeSet) {
BugPattern bugPattern = DetectorFactoryCollection.instance().lookupBugPattern(bugType);
if (bugPattern == null) {
continue;
}
Element details = root.addElement("BugPattern");
details.addAttribute("type", bugType).addAttribute("abbrev", bugPattern.getAbbrev())
.addAttribute("category", bugPattern.getCategory());
details.addElement("ShortDescription").addText(bugPattern.getShortDescription());
details.addElement("Details").addCDATA(bugPattern.getDetailText());
}
}
代码示例来源:origin: igniterealtime/Openfire
String text = pp.getText();
if (parent != null) {
parent.addCDATA(text);
代码示例来源:origin: org.dom4j/dom4j
public void endCDATA() throws SAXException {
insideCDATASection = false;
currentElement.addCDATA(cdataText.toString());
}
代码示例来源:origin: gocd/gocd
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;
}
代码示例来源:origin: gocd/gocd
public Document toXml(XmlWriterContext writerContext) {
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;
}
代码示例来源:origin: gocd/gocd
private DOMElement getXmlForJobPlan(XmlWriterContext writerContext, WaitingJobPlan waitingJobPlan) {
JobPlan jobPlan = waitingJobPlan.jobPlan();
DOMElement root = new DOMElement("job");
root.addAttribute("name", jobPlan.getName()).addAttribute("id", String.valueOf(jobPlan.getJobId()));
root.addElement("link").addAttribute("rel", "self").addAttribute("href", httpUrlFor(writerContext.getBaseUrl(), jobPlan.getIdentifier()));
root.addElement("buildLocator").addText(jobPlan.getIdentifier().buildLocator());
if (!StringUtils.isBlank(waitingJobPlan.envName())) {
root.addElement("environment").addText(waitingJobPlan.envName());
}
if (!jobPlan.getResources().isEmpty()) {
DOMElement resources = new DOMElement("resources");
for (Resource resource : jobPlan.getResources()) {
resources.addElement("resource").addCDATA(resource.getName());
}
root.add(resources);
}
if (!jobPlan.getVariables().isEmpty()) {
DOMElement envVars = new DOMElement("environmentVariables");
for (EnvironmentVariable environmentVariable : jobPlan.getVariables()) {
envVars.addElement("variable").addAttribute("name", environmentVariable.getName()).addText(environmentVariable.getDisplayValue());
}
root.add(envVars);
}
return root;
}
代码示例来源:origin: gocd/gocd
root.addElement("id").addCDATA(identifier.asURN());
String pipelineName = identifier.getPipelineName();
StageIdentifier stageId = identifier.getStageIdentifier();
properties.addElement("property").addAttribute("name", property.getKey()).addCDATA(property.getValue());
代码示例来源:origin: org.dom4j/dom4j
element.addCDATA(node.getNodeValue());
代码示例来源:origin: com.google.code.findbugs/findbugs
@Override
public void writeCDATA(String cdata) {
Element top = (Element) stack.getLast();
top.addCDATA(cdata);
}
代码示例来源:origin: pentaho/pentaho-platform
private static Element createSoapElement( String name, String value ) {
Element element = new DefaultElement( name );
element.addCDATA( value );
return element;
}
代码示例来源:origin: pentaho/pentaho-platform
private static Element createSoapElement( String name, List value ) {
Element element = new DefaultElement( name );
element.addCDATA( value.toString() );
return element;
}
代码示例来源:origin: org.dom4j/dom4j
parent.addCDATA(pp.getText());
} else {
String msg = "Cannot have text content outside of the "
代码示例来源:origin: org.opencms/opencms-core
/**
* @see org.opencms.xml.types.I_CmsXmlContentValue#setStringValue(org.opencms.file.CmsObject, java.lang.String)
*/
public void setStringValue(CmsObject cms, String value) throws CmsIllegalArgumentException {
m_element.clearContent();
if (CmsStringUtil.isNotEmpty(value)) {
m_element.addCDATA(value);
}
m_stringValue = value;
}
}
代码示例来源:origin: org.opencms/opencms-solr
/**
* @see org.opencms.xml.types.I_CmsXmlContentValue#setStringValue(org.opencms.file.CmsObject, java.lang.String)
*/
public void setStringValue(CmsObject cms, String value) throws CmsIllegalArgumentException {
m_element.clearContent();
if (CmsStringUtil.isNotEmpty(value)) {
m_element.addCDATA(value);
}
m_stringValue = value;
}
}
代码示例来源:origin: dom4j/dom4j
public void testNullCData() {
Element e = DocumentHelper.createElement("test");
e.add(DocumentHelper.createElement("another").addCDATA(null));
Document doc = DocumentHelper.createDocument(e);
assertEquals(-1, e.asXML().indexOf("null"));
assertEquals(-1, doc.asXML().indexOf("null"));
System.out.println(e.asXML());
System.out.println(doc.asXML());
}
内容来源于网络,如有侵权,请联系作者删除!