Note that there are some explanatory texts on larger screens.

plurals
  1. POAdd xml-stylesheet and get standalone = yes
    primarykey
    data
    text
    <p>I added the solution to the code below.</p> <p>The code at the bottom is what I have. I removed the creation of all tags.</p> <p>At the top in the xml file I get.<code>&lt;?xml version="1.0" encoding="UTF-8" standalone="no"?&gt;</code> Note that standalone is no, even thou I have it set to yes.</p> <p>The first question: How do I get standalone = yes?</p> <p>I would like to add <code>&lt;?xml-stylesheet type="text/xsl" href="my.stylesheet.xsl"?&gt;</code> at line two in the xml file.</p> <p>Second question: How do I do that?</p> <p>Some useful links? Anything?</p> <pre><code>DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = dbfac.newDocumentBuilder(); Document doc = docBuilder.newDocument(); doc.setXmlStandalone(true); ProcessingInstruction pi = doc.createProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" href=\"my.stylesheet.xsl\""); Element root = doc.createElement("root-element"); doc.appendChild(root); doc.insertBefore(pi, root); &lt;cut&gt; TransformerFactory transfac = TransformerFactory.newInstance(); transfac.setAttribute("indent-number", new Integer(2)); Transformer trans = transfac.newTransformer(); trans.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no"); trans.setOutputProperty(OutputKeys.STANDALONE, "yes"); trans.setOutputProperty(OutputKeys.INDENT, "yes"); trans.setOutputProperty(OutputKeys.CDATA_SECTION_ELEMENTS, "name"); FileOutputStream fout = new FileOutputStream(filepath); BufferedOutputStream bout= new BufferedOutputStream(fout); trans.transform(new DOMSource(doc), new StreamResult(new OutputStreamWriter(bout, "utf-8"))); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload