How to create these node with JDOM?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   leo_lee
Posted On:   Monday, September 17, 2001 01:48 AM

In XSLT some elements,such as :








are very hard to be created with JDOM.
How to do it?

Re: How to create these node with JDOM?

Posted By:   Denis_Navarre  
Posted On:   Monday, September 17, 2001 03:32 AM

You just have to create a "prefix" and create elements with it.
Here is a sample code creating what you want and displaying it to the console.


Here is the code:


try {

Namespace prefix = Namespace.getNamespace("xsl", "http://www.w3.org/1999/XSL/Transform");

Element elt = new Element("stylesheet", prefix).setAttribute("version","1.0");

elt.addContent(new Element("output",prefix).setAttribute("method","html").setAttribute("indent","no"));

elt.addContent(new Element("template",prefix).setAttribute("match","/html"));

XMLOutputter outputter = new XMLOutputter(" ", true, "ISO-8859-1");

outputter.output(elt, System.out);
} catch (Exception ex) {

ex.printStackTrace();

}


And here is the result:








About | Sitemap | Contact