create xsl styleshet using java code

R

rjl444

I am familier with jdom creating XML file. What I need to do is to
create XSL stylesheet instead of xml. is there any classes for this? My
app will create XSL file based on user input of nodes.
thanks
joe
 
H

Harish

an xsl is also an xml file, correct?
so whats stopping you from generating the xsl file?
 
A

au714

Use the org.jdom.Namespace class as in:


import java.io_OutputStream;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.Namespace;
import org.jdom.output.Format;
import org.jdom.output.XMLOutputter;

public class C {
public static void main(String[] args) {
Namespace xsl = Namespace.getNamespace("xsl",
"http://www.w3.org/1999/XSL/Transform");
Element root = new Element("stylesheet", xsl);
Element template = new Element("template", xsl);
template.setAttribute("match", "/");
root.addContent(template);
Document doc = new Document(root);
try {
XMLOutputter serializer = new
XMLOutputter(Format.getPrettyFormat());
serializer.output(doc, (OutputStream)System.out);
}
catch (Exception ex) {
ex.printStackTrace();
}
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top