Psst.. new poll here.
[email protected] webmail now available. Want one? Go here.
Cannot use outlook/hotmail/live here to register as they blocking our mail servers. #microsoftdeez
Obey the Epel!
Paste
Pasted as Scala by Inkvizitor ( 14 years ago )
import scala.xml._
def transform(n : Node): Node = n match
{
case x @ <citaty>{nodes @ _ * }</citaty> =>
<html>
<head>
<title>Moudrá přísloví</title>
</head>
<body>
{ transformSequence(nodes) }
</body>
</html>
case x @ <citat>{nodes @ _ * }</citat> =>
<div>
{ transformSequence(nodes) }
<hr />
</div>
case x @ <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