Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,68 @@
/* NetRexx */
options replace format comments java crossref symbols nobinary
import java.io.StringWriter
import javax.xml.
import org.w3c.dom.
class RDOMSerialization public
properties private
domDoc = Document
method main(args = String[]) public static
lcl = RDOMSerialization()
lcl.buildDOMDocument()
lcl.serializeXML()
return
method buildDOMDocument() inheritable
do
factory = DocumentBuilderFactory.newInstance()
builder = factory.newDocumentBuilder()
impl = builder.getDOMImplementation()
domDoc = impl.createDocument(null, null, null)
elmt1 = domDoc.createElement("root")
elmt2 = domDoc.createElement("element")
elmt2.setTextContent("Some text here")
domDoc.appendChild(elmt1)
elmt1.appendChild(elmt2)
catch exPC = ParserConfigurationException
exPC.printStackTrace
end
return
method serializeXML() inheritable
do
domSrc = DOMSource(domDoc)
txformer = TransformerFactory.newInstance().newTransformer()
txformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no")
txformer.setOutputProperty(OutputKeys.METHOD, "xml")
txformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8")
txformer.setOutputProperty(OutputKeys.INDENT, "yes")
txformer.setOutputProperty(OutputKeys.STANDALONE, "yes")
txformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2")
sw = StringWriter()
sr = StreamResult(sw)
txformer.transform(domSrc, sr)
say sw.toString
catch exTC = TransformerConfigurationException
exTC.printStackTrace
catch exTF = TransformerFactoryConfigurationError
exTF.printStackTrace
catch exTE = TransformerException
exTE.printStackTrace
end
return

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<root>
<element>Some text here</element>
</root>