Welcome, guest! Login / Register - Why register?
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 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">&#x2014;<em>{ t }</em></p>

}

def transformSequence(nodes: Seq[Node]) : Seq[Node] =
{
  for (cn <- nodes) yield transform(cn)
}

val input = XML.loadFile&#40;"prislovi.xml"&#41;
for (node <- transform(input))
{
  println(node)
}

 

Revise this Paste

Your Name: Code Language: