JAVA DOM API Processing inscrution and doctype before XML prolog -
i working on dom api in java, have problem, how may add precessing instruction
(xslt style sheet) , doctype
(document type) after xml prolog
each 1 in new line please?
e.g :
<?xml version="1.0" encoding="utf-8"?> <!doctype fiches system "docform.dtd"> <?xml-stylesheet type="text/xsl" href="stylesheet.xsl"?>
you need create doctype when creating document, see http://www.w3.org/tr/dom-level-3-core/core.html#id-102161490 defines method createdocumenttype
on implementation create doctype , method createdocument
create document taking doctype 1 parameter.
thus need
documenttype doctype = implementation.createdocumenttype("fiches", null, "docform.dtd"); document doc = implementation.createdocument(null, "fiches", doctype);
that way have dom document doc
doctype node , root element named fiches
, can create , insert processing instruction:
doc.insertbefore(doc.createprocessinginstruction("xml-stylesheet", "type=\"text/xsl\" href=\"stylesheet.xsl\""), doc.getdocumentelement());
Comments
Post a Comment