当前位置: 首页>>代码示例>>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;未经允许,请勿转载。