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,65 @@
/* NetRexx */
options replace format comments java crossref savelog symbols nobinary
import java.io.StringWriter
import javax.xml.parsers.DocumentBuilderFactory
import javax.xml.transform.Result
import javax.xml.transform.Source
import javax.xml.transform.Transformer
import javax.xml.transform.TransformerFactory
import javax.xml.transform.dom.DOMSource
import javax.xml.transform.stream.StreamResult
import org.w3c.dom.Document
import org.w3c.dom.Element
names = [String -
"April", "Tam O'Shanter", "Emily" -
]
remarks = [ String -
"Bubbly: I'm > Tam and <= Emily" -
, 'Burns: "When chapman billies leave the street ..."' -
, 'Short & shrift' -
]
do
-- Create a new XML document
doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument()
-- Append the root element
root = doc.createElement("CharacterRemarks")
doc.appendChild(root)
-- Read input data and create a new <Character> element for each name.
loop i_ = 0 to names.length - 1
character = doc.createElement("Character")
root.appendChild(character)
character.setAttribute("name", names[i_])
character.appendChild(doc.createTextNode(remarks[i_]))
end i_
-- Serializing XML in Java is unnecessary complicated
-- Create a Source from the document.
source = DOMSource(doc)
-- This StringWriter acts as a buffer
buffer = StringWriter()
-- Create a Result as a transformer target.
result = StreamResult(buffer)
-- The Transformer is used to copy the Source to the Result object.
transformer = TransformerFactory.newInstance().newTransformer()
transformer.setOutputProperty("indent", "yes")
transformer.transform(source, result)
-- Now the buffer is filled with the serialized XML and we can print it to the console.
say buffer.toString
catch ex = Exception
ex.printStackTrace
end
return

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<CharacterRemarks>
<Character name="April">Bubbly: I'm &gt; Tam and &lt;= Emily</Character>
<Character name="Tam O'Shanter">Burns: "When chapman billies leave the street ..."</Character>
<Character name="Emily">Short &amp; shrift</Character>
</CharacterRemarks>

View file

@ -0,0 +1,48 @@
/* NetRexx */
options replace format comments java crossref savelog symbols nobinary
import java.io.StringWriter
import javax.xml.stream.XMLOutputFactory
import javax.xml.stream.XMLStreamWriter
names = [String -
"April", "Tam O'Shanter", "Emily" -
]
remarks = [ String -
"Bubbly: I'm > Tam and <= Emily" -
, 'Burns: "When chapman billies leave the street ..."' -
, 'Short & shrift' -
]
do
buffer = StringWriter()
out = XMLOutputFactory.newInstance().createXMLStreamWriter(buffer)
out.writeStartDocument("UTF-8", "1.0")
out.writeCharacters('\n')
out.writeStartElement("CharacterRemarks")
out.writeCharacters('\n')
loop i_ = 0 to names.length - 1
out.writeStartElement("Character")
out.writeAttribute("name", names[i_])
out.writeCharacters(remarks[i_])
out.writeEndElement()
out.writeCharacters('\n')
end i_
out.writeEndElement()
out.writeEndDocument()
out.writeCharacters('\n')
say buffer.toString
catch ex = Exception
ex.printStackTrace
end
return

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<CharacterRemarks>
<Character name="April">Bubbly: I'm &gt; Tam and &lt;= Emily</Character>
<Character name="Tam O'Shanter">Burns: "When chapman billies leave the street ..."</Character>
<Character name="Emily">Short &amp; shrift</Character>
</CharacterRemarks>