src/Pure/General/xml.scala
changeset 34119 ae92efb48784
parent 34117 1eb8d8e3e40a
child 34133 17554065f3be
equal deleted inserted replaced
34118:ee9f87e11400 34119:ae92efb48784
   169         node
   169         node
   170       case Text(txt) => doc.createTextNode(txt)
   170       case Text(txt) => doc.createTextNode(txt)
   171     }
   171     }
   172     DOM(tree)
   172     DOM(tree)
   173   }
   173   }
   174 
       
   175   def document(tree: Tree, styles: String*): Document =
       
   176   {
       
   177     val doc = DocumentBuilderFactory.newInstance.newDocumentBuilder.newDocument
       
   178     doc.appendChild(doc.createProcessingInstruction("xml", "version=\"1.0\""))
       
   179 
       
   180     for (style <- styles) {
       
   181       doc.appendChild(doc.createProcessingInstruction("xml-stylesheet",
       
   182         "href=\"" + style + "\" type=\"text/css\""))
       
   183     }
       
   184     val root_elem = tree match {
       
   185       case Elem(_, _, _) => document_node(doc, tree)
       
   186       case Text(_) => document_node(doc, (Elem(Markup.ROOT, Nil, List(tree))))
       
   187     }
       
   188     doc.appendChild(root_elem)
       
   189     doc
       
   190   }
       
   191 }
   174 }