當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。