Using the following simple code:
package test;
import java.io.*;
import javax.xml.transform.*;
import javax.xml.transform.stream.*;
public class TestOutputKeys {
public static void main(String[] args) throws TransformerException {
// Instantiate transformer input
Source xmlInput = new StreamSource(new ...
|
I'm using Java's built in XML transformer to take a DOM document and print out the resulting XML. The problem is that it isn't indenting the text at all despite having ... |
I'm building an XML document and printing out into an indented format using the JVM build-in libraries. When there is a text node in the document that contains a line break, ... |
I have the following function:
private static void prettyPrint(Document doc, File destFile)
{
TransformerFactory tfactory = TransformerFactory.newInstance();
Transformer serializer;
try
{
...
|
I'm working with a DSL based on an XML schema that supports functional language features such as loops, variable state with context, and calls to external Java classes. I'd like to ... |
I would like to transform XML-document to java-tree-structure, but I do not know what is a java-tree-structure? For example, JTree or another? is it exists any library?
|
I'm transforming a DOM document to XML in java using javax.xml APIs. The result is
<tag>
<tag2>text</tag2>
</tag>
but I need it to be
<tag>
<tag2>
...
|
|
I am currently using the standard javax.xml.transform library to transform my XML to CSV using XSL. My XSL file is large - at around 950 lines. My XML files ... |
I have the next xml string -
<persons>
<person>
<name>Someone</name>
<age>27</age>
...
|
I'm working with a dynamic xml table format consisting of a schema that specifies column names and types, and a values tag which contains the rows. Simplified version of xsd below:
<xs:complexType ...
|
Assuming this input XML
<?xml version="1.0" encoding="UTF-16"?>
<test></test>
Writing these lines of code :
StreamSource source = new StreamSource(new StringReader(/* the above XML*/));
StringWriter stringWriter = new StringWriter();
StreamResult streamResult = new StreamResult(stringWriter);
TransformerFactory.newInstance().newTransformer().transform(source, streamResult);
return stringWriter.getBuffer().toString();
Outputs for me ... |
I am going to develop a database import/export feature in a JEE application.
I plan to use XML-binding solution to convert between Java object and XML file which is import/export file.
|
I'm trying to convert XML to text, using javax.xml.transform. xsltproc will correctly transform my XML to properly formatted text, while the following code produces output with almost all whitespace removed:
final ...
|
I have a piece of code like this. I found that myResults = writer.getBuffer().toString(); returns an EMPTY STRING for some of the use cases but not for the other use ... |
I need to be able to pretty print xml strings using Java APIs and have found multiple solutions for this both on the web and on this particular website. However despite ... |
Yes, I am sure we can help. But I think the XML forum will get you better and faster answers. I am going to move this thread to that forum. Good Luck Mark Let me rephrase it. Actually you already have a thread for this question in the XML forum, which is the more appropriate forum. So, in that case, this ... |
Hello, I am using javax.xml.transform.Transformer; to transform a XML file into HTML using a given XSL stylesheet, code as below. public static void transformXML(String xmlFileName) { // Change filename from .XML to .HTML String filename = xmlFileName.substring(xmlFileName.lastIndexOf("\\")); filename = filename.replaceAll(".xml", properties.getExportEXT() .toString()); try { // Create a new instance of TransformerFactory TransformerFactory tFactory = TransformerFactory.newInstance(); // Pass it a valid XSL ... |
|
Welcome to the JavaRanch, Mattew! I tend to grate my teeth when I hear the word "best", as it frequently is meaningless. The real world is a bit too complicated for "one-size-fits-all" solutions. However, a popular approach is to use XSL, since you can use a generic engine and a set of transformation rules instead of having to hard-code everything. Although ... |
Hi all, I have a webservice for encrypting a password such as that provided by the method doProcess() in MyClient class below. Currently this method processes a soap message(not shown in the code snippet) containing the plain text password and prints out the encrypted password to the console using "System.out" as shown by method process() in class EncryptionHandler below. Now, what ... |
|
Well, if you're willing to go along with the Java Beans specification (getter and setter methods for your attributes, mostly) then java.beans.XMLEncoder and java.beans.XMLDecoder would work. But if you're heavily into having your XML driven by schemas, then JAXB might be more suitable. In between there are quite a few object-binding tools available (especially if you adopt the Java attitude that ... |
|
|
catch ( TransformerException transformerException ){ transformerException.printStackTrace( System.err ); transformerException.getCause(); } } and as a result here is a snippet of the error: ERROR: '' ERROR: 'java.lang.NullPointerException' javax.xml.transform.TransformerException: javax.xml.transform.TransformerException: java.lang.NullPointerException at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:650) at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:279) at project_classes.ProfileServlet.transform(ProfileServlet.java:103) at project_classes.ProfileServlet.doGet(ProfileServlet.java:73) at javax.servlet.http.HttpServlet.service(HttpServlet.java:689) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107) ... |
|
|