當前位置: 首頁>>代碼示例>>Java>>正文


Java XMLOutputter.outputString方法代碼示例

本文整理匯總了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;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:35,代碼來源:Atom10Parser.java

示例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;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:40,代碼來源:Atom03Parser.java

示例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;
}
 
開發者ID:apache,項目名稱:incubator-taverna-plugin-bioinformatics,代碼行數:29,代碼來源:XMLUtilities.java

示例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);
}
 
開發者ID:apache,項目名稱:incubator-taverna-plugin-bioinformatics,代碼行數:33,代碼來源:XMLUtilities.java

示例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;
}
 
開發者ID:apache,項目名稱:incubator-taverna-plugin-bioinformatics,代碼行數:28,代碼來源:XMLUtilities.java

示例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;
}
 
開發者ID:apache,項目名稱:incubator-taverna-plugin-bioinformatics,代碼行數:30,代碼來源:XMLUtilities.java

示例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;
}
 
開發者ID:4thline,項目名稱:feeds,代碼行數:26,代碼來源:Atom10Parser.java

示例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;
}
 
開發者ID:medvector,項目名稱:educational-plugin,代碼行數:39,代碼來源:StudySerializationUtils.java

示例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;
}
 
開發者ID:medvector,項目名稱:educational-plugin,代碼行數:15,代碼來源:StudySerializationUtils.java

示例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;     
}
 
開發者ID:williamgrosset,項目名稱:OSCAR-ConCert,代碼行數:8,代碼來源:ArchiveDeletedRecords.java

示例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);      
}
 
開發者ID:williamgrosset,項目名稱:OSCAR-ConCert,代碼行數:13,代碼來源:ExportMeasurementType.java

示例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));
	}
}
 
開發者ID:williamgrosset,項目名稱:OSCAR-ConCert,代碼行數:33,代碼來源:RuleBaseCreator.java

示例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 "";
}
 
開發者ID:intuit,項目名稱:Tank,代碼行數:15,代碼來源:GenericXMLHandler.java

示例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");
  }
}
 
開發者ID:DeveloperFahem,項目名稱:google-apps-sso-sample,代碼行數:25,代碼來源:XmlDigitalSigner.java

示例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;
}
 
開發者ID:apache,項目名稱:incubator-taverna-plugin-bioinformatics,代碼行數:18,代碼來源:XMLUtilities.java


注:本文中的org.jdom.output.XMLOutputter.outputString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。