本文整理匯總了Java中org.jdom.output.XMLOutputter.outputString方法的典型用法代碼示例。如果您正苦於以下問題:Java XMLOutputter.outputString方法的具體用法?Java XMLOutputter.outputString怎麽用?Java XMLOutputter.outputString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.jdom.output.XMLOutputter
的用法示例。
在下文中一共展示了XMLOutputter.outputString方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: parseContent
import org.jdom.output.XMLOutputter; //導入方法依賴的package包/類
private Content parseContent(Element e) {
String value = null;
String src = e.getAttributeValue("src");//getAtomNamespace()); DONT KNOW WHY DOESN'T WORK
String type = e.getAttributeValue("type");//getAtomNamespace()); DONT KNOW WHY DOESN'T WORK
type = (type!=null) ? type : Content.TEXT;
if (type.equals(Content.TEXT)) {
// do nothing XML Parser took care of this
value = e.getText();
}
else if (type.equals(Content.HTML)) {
value = e.getText();
}
else if (type.equals(Content.XHTML)) {
XMLOutputter outputter = new XMLOutputter();
List eContent = e.getContent();
Iterator i = eContent.iterator();
while (i.hasNext()) {
org.jdom.Content c = (org.jdom.Content) i.next();
if (c instanceof Element) {
Element eC = (Element) c;
if (eC.getNamespace().equals(getAtomNamespace())) {
((Element)c).setNamespace(Namespace.NO_NAMESPACE);
}
}
}
value = outputter.outputString(eContent);
}
Content content = new Content();
content.setSrc(src);
content.setType(type);
content.setValue(value);
return content;
}
示例2: parseContent
import org.jdom.output.XMLOutputter; //導入方法依賴的package包/類
private Content parseContent(Element e) {
String value = null;
String type = e.getAttributeValue("type");//getAtomNamespace()); DONT KNOW WHY DOESN'T WORK
type = (type!=null) ? type : "text/plain";
String mode = e.getAttributeValue("mode");//getAtomNamespace())); DONT KNOW WHY DOESN'T WORK
if (mode == null) {
mode = Content.XML; // default to xml content
}
if (mode.equals(Content.ESCAPED)) {
// do nothing XML Parser took care of this
value = e.getText();
}
else
if (mode.equals(Content.BASE64)) {
value = Base64.decode(e.getText());
}
else
if (mode.equals(Content.XML)) {
XMLOutputter outputter = new XMLOutputter();
List eContent = e.getContent();
Iterator i = eContent.iterator();
while (i.hasNext()) {
org.jdom.Content c = (org.jdom.Content) i.next();
if (c instanceof Element) {
Element eC = (Element) c;
if (eC.getNamespace().equals(getAtomNamespace())) {
((Element)c).setNamespace(Namespace.NO_NAMESPACE);
}
}
}
value = outputter.outputString(eContent);
}
Content content = new Content();
content.setType(type);
content.setMode(mode);
content.setValue(value);
return content;
}
示例3: getListOfCollections
import org.jdom.output.XMLOutputter; //導入方法依賴的package包/類
/**
*
* @param message
* the String to extract the list of collections from and assumes
* that you are passing in a single invocation message.
* @return an array of Strings representing all of the fully 'wrapped'
* collections in the message.
* @throws MobyException
* if the the element contains an invalid BioMOBY message
*/
public static String[] getListOfCollections(String message)
throws MobyException {
Element element = getDOMDocument(message).getRootElement();
Element[] elements = getListOfCollections(element);
String[] strings = new String[elements.length];
XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat()
.setOmitDeclaration(false));
for (int count = 0; count < elements.length; count++) {
try {
strings[count] = outputter.outputString(elements[count]);
} catch (Exception e) {
throw new MobyException(newline
+ "Unexpected error occured while creating String[]:"
+ newline + Utils.format(e.getLocalizedMessage(), 3));
}
}
return strings;
}
示例4: getSimple
import org.jdom.output.XMLOutputter; //導入方法依賴的package包/類
/**
* This method assumes a single invocation was passed to it
* <p>
*
* @param name
* the article name of the simple that you are looking for
* @param xml
* the xml that you want to query
* @return a String object that represent the simple found.
* @throws MobyException
* if no simple was found given the article name and/or data
* type or if the xml was not valid moby xml or if an unexpected
* error occurs.
*/
public static String getSimple(String name, String xml)
throws MobyException {
Element element = getDOMDocument(xml).getRootElement();
XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat()
.setOmitDeclaration(false));
Element simples = getSimple(name, element);
if (simples != null) {
try {
return outputter.outputString(simples);
} catch (Exception e) {
throw new MobyException(newline
+ "Unexpected error occured while creating String[]:"
+ newline + Utils.format(e.getLocalizedMessage(), 3));
}
}
throw new MobyException(newline + "The simple named '" + name
+ "' was not found in the xml:" + newline + xml + newline);
}
示例5: getSimplesFromCollection
import org.jdom.output.XMLOutputter; //導入方法依賴的package包/類
/**
*
* @param name
* the name of the collection to extract the simples from.
* @param xml
* the XML to extract from
* @return an array of String objects that represent the simples
* @throws MobyException
*/
public static String[] getSimplesFromCollection(String name, String xml)
throws MobyException {
Element[] elements = getSimplesFromCollection(name, getDOMDocument(xml)
.getRootElement());
String[] strings = new String[elements.length];
XMLOutputter output = new XMLOutputter(Format.getPrettyFormat()
.setOmitDeclaration(false));
for (int i = 0; i < elements.length; i++) {
try {
strings[i] = output.outputString(elements[i]);
} catch (Exception e) {
throw new MobyException(newline
+ "Unknown error occured while creating String[]."
+ newline + Utils.format(e.getLocalizedMessage(), 3));
}
}
return strings;
}
示例6: getWrappedSimplesFromCollection
import org.jdom.output.XMLOutputter; //導入方法依賴的package包/類
/**
*
* @param name
* the name of the collection to extract the simples from.
* @param xml
* the XML to extract from
* @return an array of String objects that represent the simples, with the
* name of the collection
* @throws MobyException
* if the collection doesnt exist or the xml is invalid
*/
public static String[] getWrappedSimplesFromCollection(String name,
String xml) throws MobyException {
Element[] elements = getWrappedSimplesFromCollection(name,
getDOMDocument(xml).getRootElement());
String[] strings = new String[elements.length];
XMLOutputter output = new XMLOutputter(Format.getPrettyFormat()
.setOmitDeclaration(false));
for (int i = 0; i < elements.length; i++) {
try {
strings[i] = output.outputString(elements[i]);
} catch (Exception e) {
throw new MobyException(newline
+ "Unknown error occured while creating String[]."
+ newline + Utils.format(e.getLocalizedMessage(), 3));
}
}
return strings;
}
示例7: parseTextConstructToString
import org.jdom.output.XMLOutputter; //導入方法依賴的package包/類
private String parseTextConstructToString(Element e) {
String value = null;
String type = getAttributeValue(e, "type");
type = (type!=null) ? type : Content.TEXT;
if (type.equals(Content.XHTML) || (type.indexOf("/xml")) != -1 || (type.indexOf("+xml")) != -1) {
// XHTML content needs special handling
XMLOutputter outputter = new XMLOutputter();
List eContent = e.getContent();
Iterator i = eContent.iterator();
while (i.hasNext()) {
org.jdom.Content c = (org.jdom.Content) i.next();
if (c instanceof Element) {
Element eC = (Element) c;
if (eC.getNamespace().equals(getAtomNamespace())) {
((Element)c).setNamespace(Namespace.NO_NAMESPACE);
}
}
}
value = outputter.outputString(eContent);
} else {
// Everything else comes in verbatim
value = e.getText();
}
return value;
}
示例8: convertToThirdVersion
import org.jdom.output.XMLOutputter; //導入方法依賴的package包/類
public static Element convertToThirdVersion(Element state, Project project) throws StudyUnrecognizedFormatException {
Element taskManagerElement = state.getChild(MAIN_ELEMENT);
XMLOutputter outputter = new XMLOutputter();
Map<String, String> placeholderTextToStatus = fillStatusMap(taskManagerElement, STUDY_STATUS_MAP, outputter);
Map<String, String> taskFileToStatusMap = fillStatusMap(taskManagerElement, TASK_STATUS_MAP, outputter);
Element courseElement = getChildWithName(taskManagerElement, COURSE).getChild(COURSE_TITLED);
for (Element lesson : getChildList(courseElement, LESSONS)) {
int lessonIndex = getAsInt(lesson, INDEX);
for (Element task : getChildList(lesson, TASK_LIST)) {
String taskStatus = null;
int taskIndex = getAsInt(task, INDEX);
Map<String, Element> taskFiles = getChildMap(task, TASK_FILES);
for (Map.Entry<String, Element> entry : taskFiles.entrySet()) {
Element taskFileElement = entry.getValue();
String taskFileText = outputter.outputString(taskFileElement);
String taskFileStatus = taskFileToStatusMap.get(taskFileText);
if (taskFileStatus != null && (taskStatus == null || taskFileStatus.equals(StudyStatus.Failed.toString()))) {
taskStatus = taskFileStatus;
}
Document document = StudyUtils.getDocument(project.getBasePath(), lessonIndex, taskIndex, entry.getKey());
if (document == null) {
continue;
}
for (Element placeholder : getChildList(taskFileElement, ANSWER_PLACEHOLDERS)) {
taskStatus = addStatus(outputter, placeholderTextToStatus, taskStatus, placeholder);
addOffset(document, placeholder);
addInitialState(document, placeholder);
}
}
if (taskStatus != null) {
addChildWithName(task, STATUS, taskStatus);
}
}
}
return state;
}
示例9: addStatus
import org.jdom.output.XMLOutputter; //導入方法依賴的package包/類
public static String addStatus(XMLOutputter outputter,
Map<String, String> placeholderTextToStatus,
String taskStatus,
Element placeholder) {
String placeholderText = outputter.outputString(placeholder);
String status = placeholderTextToStatus.get(placeholderText);
if (status != null) {
addChildWithName(placeholder, STATUS, status);
if (taskStatus == null || status.equals(StudyStatus.Failed.toString())) {
taskStatus = status;
}
}
return taskStatus;
}
示例10: getStringXmlFromResultSet
import org.jdom.output.XMLOutputter; //導入方法依賴的package包/類
private String getStringXmlFromResultSet(ProviderLabRoutingModel record) throws Exception{
ResultSetBuilder builder = new ResultSetBuilder(record);
Document doc = builder.build();
XMLOutputter xml = new XMLOutputter();
String xmlStr = xml.outputString(doc);
return xmlStr;
}
示例11: export
import org.jdom.output.XMLOutputter; //導入方法依賴的package包/類
public String export (EctMeasurementTypesBean mtb){
Element measurement = createXMLMeasurement(mtb.getType(),mtb.getTypeDesc(),mtb.getTypeDisplayName(),mtb.getMeasuringInstrc());
EctValidationsBeanHandler valBeanHandler = new EctValidationsBeanHandler();
EctValidationsBean v = valBeanHandler.getValidation(mtb.getValidationName());//(EctValidationsBean) validationRules.get(i);
measurement.addContent(createXMLValidation(v.getName(),v.getMaxValue(),v.getMinValue(),v.getIsDate(),v.getIsNumeric(),v.getRegularExp(),v.getMaxLength(),v.getMinLength()));
XMLOutputter outp = new XMLOutputter();
outp.setFormat(Format.getPrettyFormat());
return outp.outputString(measurement);
}
示例12: getRuleBase
import org.jdom.output.XMLOutputter; //導入方法依賴的package包/類
public RuleBase getRuleBase(String rulesetName, List<Element> elementRules) throws Exception {
long timer = System.currentTimeMillis();
try {
Element va = new Element("rule-set");
addAttributeifValueNotNull(va, "name", rulesetName);
va.setNamespace(namespace);
va.addNamespaceDeclaration(javaNamespace);
va.addNamespaceDeclaration(xsNs);
va.setAttribute("schemaLocation", "http://drools.org/rules rules.xsd http://drools.org/semantics/java java.xsd", xsNs);
for (Element ele : elementRules) {
va.addContent(ele);
}
XMLOutputter outp = new XMLOutputter();
outp.setFormat(Format.getPrettyFormat());
String ooo = outp.outputString(va);
log.debug(ooo);
RuleBase ruleBase=RuleBaseFactory.getRuleBase("RuleBaseCreator:"+ooo);
if (ruleBase!=null) return(ruleBase);
ruleBase = RuleBaseLoader.loadFromInputStream(new ByteArrayInputStream(ooo.getBytes()));
RuleBaseFactory.putRuleBase("RuleBaseCreator:"+ooo, ruleBase);
return ruleBase;
} finally {
log.debug("generateRuleBase TimeMs : " + (System.currentTimeMillis() - timer));
}
}
示例13: toString
import org.jdom.output.XMLOutputter; //導入方法依賴的package包/類
/**
* Return the xml document in a String object
*/
public String toString() {
if (this.xmlDocument != null) {
XMLOutputter outputter = new XMLOutputter();
String output = outputter.outputString(this.xmlDocument);
output = output.replaceAll("\r", "");
output = output.replaceAll("\n", "");
output = output.replaceAll("\t", "");
return output;
}
return "";
}
示例14: signXML
import org.jdom.output.XMLOutputter; //導入方法依賴的package包/類
/**
* Signs the specified xmlString with the pair of provided keys, as per the
* SAML 2.0 specifications. Returns String format of signed XML if
* successfully signed, returns null otherwise.
*
* @param samlResponse SAML Response XML file to be signed
* @param publicKey public key to read the signed XML
* @param privateKey private key to sign the XML
* @return String format of signed XML if signed correctly, null otherwise
*/
public static String signXML(String samlResponse, PublicKey publicKey,
PrivateKey privateKey) throws SamlException {
Document doc = Util.createJdomDoc(samlResponse);
if (doc != null) {
// create a new root element by signing it with the supplied keys
Element signedElement = signSamlElement(doc.getRootElement(), privateKey,
publicKey);
doc.setRootElement((Element) signedElement.detach());
XMLOutputter xmlOutputter = new XMLOutputter();
return (xmlOutputter.outputString(doc));
} else {
throw new SamlException("Error signing SAML Response: Null document");
}
}
示例15: getCollection
import org.jdom.output.XMLOutputter; //導入方法依賴的package包/類
/**
*
* @param name
* @param xml
* @return
* @throws MobyException
*/
public static String getCollection(String name, String xml)
throws MobyException {
Element element = getDOMDocument(xml).getRootElement();
XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat()
.setOmitDeclaration(false));
Element collection = getCollection(name, element);
if (collection != null)
return outputter.outputString(collection);
return null;
}