PDA

View Full Version : adding the XSL reference to a XML file automatically


D_12
10-26-2005, 08:22 PM
I have a .jar application which enables the user to input information and then saves it as a XML file.

I want to add
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="style.xsl"?>

to the top of the XML document when saving the information as an XML file.

I know that the way to add the declaration '<?xml version="1.0" encoding="UTF-8"?>' to a document using java is :

DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.newDocument();

I was wondering if you could tell me what the Java code is for adding the reference to the xsl file '<?xml-stylesheet type="text/xsl" href="style.xsl"?>' was?

Thanks.