当前位置: 首页>>代码示例>>Java>>正文


Java XMLOutputter类代码示例

本文整理汇总了Java中org.jdom.output.XMLOutputter的典型用法代码示例。如果您正苦于以下问题:Java XMLOutputter类的具体用法?Java XMLOutputter怎么用?Java XMLOutputter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


XMLOutputter类属于org.jdom.output包,在下文中一共展示了XMLOutputter类的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: doOutput

import org.jdom.output.XMLOutputter; //导入依赖的package包/类
public void doOutput(List<StudentEntity> students){
	  	Element root = new Element("students");  
        Document document = new Document(root);  
        Iterator<StudentEntity> iter = students.iterator();
        while(iter.hasNext()){
        	StudentEntity student = iter.next();
        	Element studentEl = new Element("student");
        	studentEl.addContent(new Element("studentnumber").setText(student.getStudentNumber()));
        	studentEl.addContent(new Element("studentname").setText(student.getStudentName()));
        	studentEl.addContent(new Element("major").setText(student.getMajor()));
        	studentEl.addContent(new Element("grade").setText(student.getGrade()));
        	studentEl.addContent(new Element("classname").setText(student.getClassName()));
        	studentEl.addContent(new Element("gender").setText(student.getGender()));
        	root.addContent(studentEl);
        }
        try {
	        XMLOutputter out = new XMLOutputter();  
            Format f = Format.getPrettyFormat();  
            f.setEncoding("UTF-8");
            out.setFormat(f);  
            out.output(document, new FileOutputStream(outputFile)); 
        } catch (Exception e) {  
            e.printStackTrace();  
        }  
}
 
开发者ID:ousheobin,项目名称:My-Javaweb-Homework,代码行数:26,代码来源:XMLOutputUtil.java

示例4: executeForArrayType

import org.jdom.output.XMLOutputter; //导入依赖的package包/类
private void executeForArrayType(Map<String, Object> result,
		List<Element> children) {
	ArrayTypeDescriptor arrayDescriptor = (ArrayTypeDescriptor) typeDescriptor;
	List<String> values = new ArrayList<String>();
	XMLOutputter outputter = new XMLOutputter();

	boolean isInnerBaseType = arrayDescriptor.getElementType() instanceof BaseTypeDescriptor;
	if (isInnerBaseType) {
		values = extractBaseTypeArrayFromChildren(children);
	} else {
		for (Element child : children) {
			values.add(outputter.outputString(child));
		}
	}
	result.put(outputNames[0], values);
}
 
开发者ID:apache,项目名称:incubator-taverna-common-activities,代码行数:17,代码来源:XMLOutputSplitter.java

示例5: toDom

import org.jdom.output.XMLOutputter; //导入依赖的package包/类
/**
 * Convert the received jdom doc to a Document element.
 *
 * @param doc the doc
 * @return the org.w3c.dom. document
 */
private org.w3c.dom.Document toDom(final Document doc) {
    try {
        final XMLOutputter xmlOutputter = new XMLOutputter();
        final StringWriter elemStrWriter = new StringWriter();
        xmlOutputter.output(doc, elemStrWriter);
        final byte[] xmlBytes = elemStrWriter.toString().getBytes(Charset.defaultCharset());
        final DocumentBuilderFactory dbf = DocumentBuilderFactory
                .newInstance();
        dbf.setNamespaceAware(true);
        return dbf.newDocumentBuilder().parse(
                new ByteArrayInputStream(xmlBytes));
    } catch (final Exception e) {
        logger.trace(e.getMessage(), e);
        return null;
    }
}
 
开发者ID:xuchengdong,项目名称:cas4.1.9,代码行数:23,代码来源:AbstractSamlObjectBuilder.java

示例6: writeToXml

import org.jdom.output.XMLOutputter; //导入依赖的package包/类
/**
 * Writes the JDOM document to the outputstream specified
 * @param out	the outputstream to which the JDOM document should be writed
 * @param validate if true, validate the dom structure before writing. If there is a validation error,
 * 		or the xsd is not in the classpath, an exception will be thrown.
 * @throws ConverterException
 */
public void writeToXml(Pathway pwy, OutputStream out, boolean validate) throws ConverterException {
	Document doc = createJdom(pwy);
	
	//Validate the JDOM document
	if (validate) validateDocument(doc);
	//			Get the XML code
	XMLOutputter xmlcode = new XMLOutputter(Format.getPrettyFormat());
	Format f = xmlcode.getFormat();
	f.setEncoding("UTF-8");
	f.setTextMode(Format.TextMode.PRESERVE);
	xmlcode.setFormat(f);

	try
	{
		//Send XML code to the outputstream
		xmlcode.output(doc, out);
	}
	catch (IOException ie)
	{
		throw new ConverterException(ie);
	}
}
 
开发者ID:PathVisio,项目名称:pathvisio,代码行数:30,代码来源:GpmlFormat2010a.java

示例7: getSortedXml

import org.jdom.output.XMLOutputter; //导入依赖的package包/类
/**
 * Returns the sorted xml as an OutputStream.
 *
 * @return the sorted xml
 */
public String getSortedXml(Document newDocument) {
    try (ByteArrayOutputStream sortedXml = new ByteArrayOutputStream()) {
        BufferedLineSeparatorOutputStream bufferedLineOutputStream =
                new BufferedLineSeparatorOutputStream(lineSeparatorUtil.toString(), sortedXml);

        XMLOutputter xmlOutputter = new PatchedXMLOutputter(bufferedLineOutputStream, indentBlankLines);
        xmlOutputter.setFormat(createPrettyFormat());
        xmlOutputter.output(newDocument, bufferedLineOutputStream);

        IOUtils.closeQuietly(bufferedLineOutputStream);
        return sortedXml.toString(encoding);
    } catch (IOException ioex) {
        throw new FailureException("Could not format pom files content", ioex);
    }
}
 
开发者ID:Ekryd,项目名称:sortpom,代码行数:21,代码来源:XmlOutputGenerator.java

示例8: writeXMLDocument

import org.jdom.output.XMLOutputter; //导入依赖的package包/类
public static boolean writeXMLDocument(Document doc, String fName) throws FileNotFoundException {
	// Assert.assertNotNull(doc);
	if (doc == null)
	    _log.error("null document");
	else {
	    final long start = System.currentTimeMillis();
	    FileOutputStream fos = new FileOutputStream(fName);
	    try {
	        XMLOutputter outputter = new XMLOutputter();
	        outputter.setFormat(Format.getPrettyFormat());
	        outputter.output(doc, fos);
	        return true;
	    } catch (IOException ioe) {
	        _log.error(ioe);
	    }
	    _log.trace("Document written to " + fName + " in: " + TimeUtility.msToHumanReadableDelta(start));
	}
	return false;
}
 
开发者ID:brunyuriy,项目名称:crystalvc,代码行数:20,代码来源:XMLTools.java

示例9: write

import org.jdom.output.XMLOutputter; //导入依赖的package包/类
static void write(File file) throws FileNotFoundException, IOException{
	Document document = new Document();
	Element root = new Element("document");
	root.setAttribute("version", Main.VERSION_ID);
	for(Blueprint bp : Main.blueprints){
		
		Element blueprint = writeGraphEditor(bp);
		
		for(VFunction f : bp.getFunctions()){
			blueprint.addContent(writeGraphEditor(f.getEditor()));
		}
		
		root.addContent(blueprint);
	}
	document.setRootElement(root);
	XMLOutputter output = new XMLOutputter();
	Format format = Format.getPrettyFormat();//getRawFormat();
	format.setOmitDeclaration(true);
	format.setOmitEncoding(true);
	format.setTextMode(TextMode.PRESERVE);
	output.setFormat(format);
	output.output(document, new FileOutputStream(file));
}
 
开发者ID:QuinnFreedman,项目名称:THINK-VPL,代码行数:24,代码来源:SaveFileIO.java

示例10: 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

示例11: 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

示例12: 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

示例13: printXML

import org.jdom.output.XMLOutputter; //导入依赖的package包/类
public static void printXML(Element element){
	Format format = Format.getPrettyFormat();
	format.setIndent("\t");
	XMLOutputter op = new XMLOutputter(format);
	if(element == null){
		System.err.println("Null element");
	}
	else{
		try {
			op.output(element, System.out);
		} catch (IOException e) {
			e.printStackTrace();
		}
		System.out.println();
	}
}
 
开发者ID:tvaquero,项目名称:itsimple,代码行数:17,代码来源:XMLUtilities.java

示例14: testInsertAtPreferredLocation

import org.jdom.output.XMLOutputter; //导入依赖的package包/类
public void testInsertAtPreferredLocation() throws Exception {
    NetbeansBuildActionJDOMWriter writer = new NetbeansBuildActionJDOMWriter();
    XMLOutputter xmlout = new XMLOutputter();
    xmlout.setFormat(Format.getRawFormat().setLineSeparator("\n"));
    Element p = new Element("p");
    NetbeansBuildActionJDOMWriter.Counter c = writer.new Counter(1);
    writer.insertAtPreferredLocation(p, new Element("one"), c);
    assertEquals("<p>\n    <one />\n</p>", xmlout.outputString(p));
    c.increaseCount();
    writer.insertAtPreferredLocation(p, new Element("two"), c);
    assertEquals("<p>\n    <one />\n    <two />\n</p>", xmlout.outputString(p));
    c = writer.new Counter(1);
    writer.insertAtPreferredLocation(p, new Element("zero"), c);
    assertEquals("<p>\n    <zero />\n    <one />\n    <two />\n</p>", xmlout.outputString(p));
    c.increaseCount();
    writer.insertAtPreferredLocation(p, new Element("hemi"), c);
    assertEquals("<p>\n    <zero />\n    <hemi />\n    <one />\n    <two />\n</p>", xmlout.outputString(p));
    c.increaseCount();
    c.increaseCount();
    writer.insertAtPreferredLocation(p, new Element("sesqui"), c);
    assertEquals("<p>\n    <zero />\n    <hemi />\n    <one />\n    <sesqui />\n    <two />\n</p>", xmlout.outputString(p));
    c.increaseCount();
    c.increaseCount();
    writer.insertAtPreferredLocation(p, new Element("ultimate"), c);
    assertEquals("<p>\n    <zero />\n    <hemi />\n    <one />\n    <sesqui />\n    <two />\n    <ultimate />\n</p>", xmlout.outputString(p));
    c = writer.new Counter(1);
    writer.insertAtPreferredLocation(p, new Element("initial"), c);
    assertEquals("<p>\n    <initial />\n    <zero />\n    <hemi />\n    <one />\n    <sesqui />\n    <two />\n    <ultimate />\n</p>", xmlout.outputString(p));
    // XXX indentation still not right; better to black-box test write(ActionToGoalMapping...)
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:NetbeansBuildActionJDOMWriterTest.java

示例15: toDom

import org.jdom.output.XMLOutputter; //导入依赖的package包/类
/**
 * Convert the received jdom doc to a Document element.
 *
 * @param doc the doc
 * @return the org.w3c.dom. document
 */
private static org.w3c.dom.Document toDom(final Document doc) {
    try {
        final XMLOutputter xmlOutputter = new XMLOutputter();
        final StringWriter elemStrWriter = new StringWriter();
        xmlOutputter.output(doc, elemStrWriter);
        final byte[] xmlBytes = elemStrWriter.toString().getBytes(Charset.defaultCharset());
        final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        dbf.setNamespaceAware(true);
        dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
        dbf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
        dbf.setFeature("http://apache.org/xml/features/validation/schema/normalized-value", false);
        dbf.setFeature("http://javax.xml.XMLConstants/feature/secure-processing", true);
        dbf.setFeature("http://xml.org/sax/features/external-general-entities", false);
        dbf.setFeature("http://xml.org/sax/features/external-parameter-entities", false);

        return dbf.newDocumentBuilder().parse(new ByteArrayInputStream(xmlBytes));
    } catch (final Exception e) {
        LOGGER.trace(e.getMessage(), e);
        return null;
    }
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:28,代码来源:AbstractSamlObjectBuilder.java


注:本文中的org.jdom.output.XMLOutputter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。