Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so dont bother with any of their useless mail servers here and just use oauth login instead. Thank the nice Russians for causing that. :)
Paste
Pasted as Scala by Inkvizitor ( 17 years ago )
import scala.xml._
def transform(n : Node): Node = n match
{
case <citaty>{nodes @ _ * }</citaty> =>
<html>
<head>
<title>Moudrá přísloví</title>
</head>
<body>
{ transformSequence(nodes) }
</body>
</html>
case <citat>{nodes @ _ * }</citat> =>
<div>
{ transformSequence(nodes) }
<hr />
</div>
case <text>{ t }</text> =>
<p>
{ t }
</p>
case x @ <autor>{ t }</autor> => <p align="right">—<em>{ t }</em></p>
}
def transformSequence(nodes: Seq[Node]) : Seq[Node] =
{
for (cn <- nodes) yield transform(cn)
}
val input = XML.loadFile("prislovi.xml")
for (node <- transform(input))
{
println(node)
}
Revise this Paste