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


Java TransformerException.printStackTrace方法代码示例

本文整理汇总了Java中javax.xml.transform.TransformerException.printStackTrace方法的典型用法代码示例。如果您正苦于以下问题:Java TransformerException.printStackTrace方法的具体用法?Java TransformerException.printStackTrace怎么用?Java TransformerException.printStackTrace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.xml.transform.TransformerException的用法示例。


在下文中一共展示了TransformerException.printStackTrace方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: toString

import javax.xml.transform.TransformerException; //导入方法依赖的package包/类
/**
 * the format should be something like this: [ ['My Workspace', null, ['Mary Morgan Folder', null, ['3 activity
 * sequence','1024'] ], ['Organisations', null, ['Developers Playpen', null, ['Lesson Sequence Folder', null,
 * ['',null] ] ], ['MATH111', null, ['Lesson Sequence Folder', null, ['',null] ] ] ] ] ]
 */
@Override
public String toString() {
    // return '[' + convert() + ']';

    Document document = getDocument();

    try {
	DOMSource domSource = new DOMSource(document);
	StringWriter writer = new StringWriter();
	StreamResult result = new StreamResult(writer);
	TransformerFactory tf = TransformerFactory.newInstance();
	Transformer transformer = tf.newTransformer();
	transformer.transform(domSource, result);
	return writer.toString();
    } catch (TransformerException ex) {
	ex.printStackTrace();
	return null;
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:LearningDesignRepositoryServlet.java

示例2: save

import javax.xml.transform.TransformerException; //导入方法依赖的package包/类
public static void save(String paramString, Document paramDocument) throws Exception {
	DOMSource localDOMSource = new DOMSource(paramDocument);
	File localFile1 = new File(paramString);
	File localFile2 = localFile1.getParentFile();
	localFile2.mkdirs();
	StreamResult localStreamResult = new StreamResult(localFile1);
	try {
		TransformerFactory localTransformerFactory = TransformerFactory.newInstance();
		Transformer localTransformer = localTransformerFactory.newTransformer();
		Properties localProperties = localTransformer.getOutputProperties();
		localProperties.setProperty("encoding", "UTF-8");
		localProperties.setProperty("indent", "yes");
		localTransformer.setOutputProperties(localProperties);
		localTransformer.transform(localDOMSource, localStreamResult);
	} catch (TransformerConfigurationException localTransformerConfigurationException) {
		localTransformerConfigurationException.printStackTrace();
	} catch (TransformerException localTransformerException) {
		localTransformerException.printStackTrace();
	}
}
 
开发者ID:inspingcc,项目名称:LibraSock,代码行数:21,代码来源:XmlUtils.java

示例3: docToString

import javax.xml.transform.TransformerException; //导入方法依赖的package包/类
/**
 * Transforms a DOM document to string.
 * @param doc the document to transform
 * @return the string representation of the doc or an empty string if sth. went wrong
 */
public static String docToString(Document doc, boolean indent){
    try {
        StringWriter writer = new StringWriter();
        Transformer transformer = TransformerFactory.newInstance().newTransformer();
        if (indent) {
            transformer.setOutputProperty(OutputKeys.INDENT, "yes");
            transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
        }
        transformer.transform(new DOMSource(doc), new StreamResult(writer));
        return writer.getBuffer().toString();
    } catch (TransformerException e) {
        e.printStackTrace();
    }
    return "";
}
 
开发者ID:agentcontest,项目名称:massim,代码行数:21,代码来源:Conversions.java

示例4: export

import javax.xml.transform.TransformerException; //导入方法依赖的package包/类
public void export(File file) {
	try {
		// Create the GraphML Document
		docFactory = DocumentBuilderFactory.newInstance();
		docBuilder = docFactory.newDocumentBuilder();
		doc = docBuilder.newDocument();

		// Export the data
		exportData();

		// Save data as GraphML file
		Transformer transformer = TransformerFactory.newInstance()
				.newTransformer();
		DOMSource source = new DOMSource(doc);
		StreamResult result = new StreamResult(file);
		transformer.setOutputProperty(OutputKeys.INDENT, "yes");
		transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
		transformer.transform(source, result);

	} catch (TransformerException te) {
		te.printStackTrace();
	} catch (ParserConfigurationException pce) {
		pce.printStackTrace();
	}
}
 
开发者ID:dev-cuttlefish,项目名称:cuttlefish,代码行数:26,代码来源:GraphMLExporter.java

示例5: setServiceDescriptionName

import javax.xml.transform.TransformerException; //导入方法依赖的package包/类
/**
 * Sets the service description name.
 *
 * @param serviceDescriptionFile the service description file
 * @param serviceName the service name
 */
private void setServiceDescriptionName(File serviceDescriptionFile) {
	
	String newServiceName = this.getSymbolicBundleName() + "." + CLASS_LOAD_SERVICE_NAME;
	
	try {
		// --- Open the XML document ------------------
		DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
		DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
		Document doc = docBuilder.parse(serviceDescriptionFile);
		
		// --- Get the XML root/component element -----
		Node component = doc.getFirstChild();
		NamedNodeMap componentAttr = component.getAttributes();
		Node nameAttr = componentAttr.getNamedItem("name");
		nameAttr.setTextContent(newServiceName);
		
		// --- Save document in XML file --------------	
		TransformerFactory transformerFactory = TransformerFactory.newInstance();
		Transformer transformer = transformerFactory.newTransformer();
		DOMSource source = new DOMSource(doc);
		StreamResult result = new StreamResult(serviceDescriptionFile);
		transformer.transform(source, result);
		
	} catch (ParserConfigurationException pcEx) {
		pcEx.printStackTrace();
	} catch (SAXException saxEx) {
		saxEx.printStackTrace();
	} catch (IOException ioEx) {
		ioEx.printStackTrace();
	} catch (TransformerConfigurationException tcEx) {
		tcEx.printStackTrace();
	} catch (TransformerException tEx) {
		tEx.printStackTrace();
	}
	
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:43,代码来源:BundleBuilder.java

示例6: exportXMI

import javax.xml.transform.TransformerException; //导入方法依赖的package包/类
public static void exportXMI(Graph pGraph, String path){
    try{
        TransformerFactory transformerFactory = TransformerFactory.newInstance();
        Transformer transformer = transformerFactory.newTransformer();

        DOMSource source = new DOMSource(createXmi(pGraph));

        StreamResult result = new StreamResult(new File(path));
        transformer.transform(source, result);
    } catch (TransformerException tfe) {
        tfe.printStackTrace();
    }
}
 
开发者ID:kaanburaksener,项目名称:octoBubbles,代码行数:14,代码来源:PersistenceManager.java

示例7: write

import javax.xml.transform.TransformerException; //导入方法依赖的package包/类
protected void write(PrintWriter writer) {
	try {
		TransformerFactory transformerFactory = TransformerFactory
				.newInstance();
		Transformer transformer = transformerFactory.newTransformer();
		transformer.setOutputProperty(OutputKeys.INDENT, "yes");
		DOMSource source = new DOMSource(document);
		StreamResult result = new StreamResult(writer);
		transformer.transform(source, result);
	} catch (TransformerException e) {
		e.printStackTrace();
		throw new RuntimeException(e);
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:15,代码来源:AbstractXMLGenerator.java

示例8: SaveOrganism

import javax.xml.transform.TransformerException; //导入方法依赖的package包/类
public void SaveOrganism(Organism organism, int round) {
    Document doc = OpenDoc();

    Element rootElement = (Element)doc.getFirstChild();
    NodeList organisms = rootElement.getElementsByTagName("organism");

    Element eOrganism = null;
    boolean found = false;
    for (int i = 0; i < organisms.getLength(); i++) {
        eOrganism = (Element)organisms.item(i);
        if(Integer.parseInt(((Element)organisms.item(i)).getAttribute("id")) == organism.id) {
            found = true;
            break;
        }
    }

    if(!found) {
        eOrganism = doc.createElement("organism");
        eOrganism.setAttribute("id", Integer.toString(organism.id));
        rootElement.appendChild(eOrganism);
    }

    Element grid = doc.createElement("grid");
    grid.setAttribute("iteration", Integer.toString(round));
    eOrganism.appendChild(grid);
    Element size = doc.createElement("size");
    size.appendChild(doc.createTextNode(organism.grid.size.x + "," + organism.grid.size.y));

    Element points = doc.createElement("points");
    points.appendChild(doc.createTextNode(Integer.toString(organism.points)));
    grid.appendChild(points);

    for (int x = 0; x < organism.grid.size.x; x++) {
        for (int y = 0; y < organism.grid.size.y; y++) {
            Element slot = doc.createElement("slot");
            slot.appendChild(ParseComponent((IComponent)organism.grid.contents[y][x], doc)); //error
            slot.setAttribute("x", Integer.toString(x));
            slot.setAttribute("y", Integer.toString(y));
            grid.appendChild(slot);
        }
    }

    try {
        TransformerFactory transformerFactory = TransformerFactory.newInstance();
        Transformer transformer = transformerFactory.newTransformer();
        DOMSource source = new DOMSource(doc);
        StreamResult result = new StreamResult(new File(filepath));

        transformer.transform(source, result);
    } catch (TransformerException tfe) {
        tfe.printStackTrace();
    }
}
 
开发者ID:Majiick,项目名称:MicroSim,代码行数:54,代码来源:XML.java

示例9: generateUID

import javax.xml.transform.TransformerException; //导入方法依赖的package包/类
public void generateUID() {
	try {
		DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
		DocumentBuilder docBuilder = docFactory.newDocumentBuilder();

		Document doc = docBuilder.newDocument();

		// Create the root element
		Element rootElement = doc.createElement("ID_map");
		rootElement.setAttribute("xmlns", "http://www.ecoa.technology/uid-1.0");
		doc.appendChild(rootElement);

		// Add introductory text
		rootElement.appendChild(doc.createComment("This file was created by the MAI ECOA_UID_Plugin"));
		rootElement.appendChild(doc.createComment("This file contains a map allocating a numeric ID for the composite, provided service and service operation in each wire"));
		rootElement.appendChild(doc.createComment("Every ID is a positive 32-bit integer"));

		// Set the Composite ID
		writeCompositeID(doc, rootElement);

		// Set the Provided Service IDs
		writeServiceIDs(doc, rootElement);

		// Set the Service Operation IDs
		writeServiceOpIDs(doc, rootElement);

		// Write the content
		TransformerFactory transformerFactory = TransformerFactory.newInstance();
		Transformer transformer = transformerFactory.newTransformer();
		DOMSource source = new DOMSource(doc);
		StreamResult result = new StreamResult(new File(projectLocation + "/5-Integration/maiIDs.xml"));

		transformer.setOutputProperty(OutputKeys.INDENT, "yes");
		transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
		transformer.transform(source, result);

		LOGGER.info("UID file successfully created!");
	} catch (ParserConfigurationException pce) {
		pce.printStackTrace();
	} catch (TransformerException tfe) {
		tfe.printStackTrace();
	}
}
 
开发者ID:dstl,项目名称:Open_Source_ECOA_Toolset_AS5,代码行数:44,代码来源:ECOA_UID_Gen.java

示例10: generateDocumentation

import javax.xml.transform.TransformerException; //导入方法依赖的package包/类
public static void generateDocumentation(String[] languages) {
    for (String name : sourceFiles) {

        String languageCode = name.substring(15, name.length() - 11);
        if (languageCode.isEmpty()) {
            languageCode = "en";
        } else if ('_' == languageCode.charAt(0)) {
            languageCode = languageCode.substring(1);
            if ("qqq".equals(languageCode)) {
                System.out.println("Skipping language code 'qqq'");
                continue;
            }
        } else {
            // don't know what to do
            continue;
        }
        if (languages.length == 0
                || Arrays.binarySearch(languages, languageCode) >= 0) {
            System.out.println("Generating localized documentation for language code "
                                       + languageCode);

            Messages.loadMessageBundle(Messages.getLocale(languageCode));
            try {
                TransformerFactory factory = TransformerFactory.newInstance();
                Source xsl = new StreamSource(new File("doc", XSL));
                Transformer stylesheet;
                try {
                    stylesheet = factory.newTransformer(xsl);
                } catch (TransformerException tce) {
                    System.err.println("Problem with " + XSL + " at: "
                                               + tce.getLocationAsString());
                    tce.printStackTrace();
                    continue;
                }

                Source request  = new StreamSource(new File(RULE_DIRECTORY, "specification.xml"));
                Result response = new StreamResult(new File(DESTINATION_DIRECTORY, "specification_"
                        + languageCode + ".html"));
                stylesheet.transform(request, response);
            }
            catch (TransformerException e) {
                e.printStackTrace();
            }
        }
    }
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:47,代码来源:GenerateDocumentation.java


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