Skip to main content

how to add xml-stylesheet tag to XML header??

1 reply [Last post]
naure
Offline
Joined: 2004-10-29
Points: 0

Hello... i generate a XML file with the following code:

DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document dom = db.newDocument();
Element root= dom.createElement("something");
dom.appendChild(raiz);
//add more nodes to root here

/*** print to file ***/
OutputFormat format = new OutputFormat(dom);
format.setIndenting(true);
XMLSerializer serializer = new XMLSerializer(new FileOutputStream(new File("contratos.xml")), format);
serializer.serialize(dom);

and the generated XML header is like
<?xml version="1.0" encoding="UTF-8"?>

and I wanted it to be
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="relatorio.xsl" ?>

how can I do that?
thanks

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
makaslam
Offline
Joined: 2007-12-12
Points: 0

Just provide name of element having ID attribute as IDREF attribute value instead of providing ID itself