6. // immediate descendant of document called 'child'
document quot;childquot;
// any descendant of document called 'another_grandchild'
document quot;another_grandchildquot;
// any descendant attribute called 'an_attribute'
document quot;@an_attributequot;
8. • match single node with {variable}
• match node sequence with {variable @ _*}
• cannot match attribute directly
9. val a = document match {
case Elem(_, quot;rootquot;, _, _, _*) => true
case _ => null
}
10. val a = document match {
case <root>{ _* }</root> => true
case _ => false
}
11. def process(node: scala.xml.Node): Unit = {
println(node)
node match {
case <root>{contents @ _* }</root> =>
for (a <- contents) process(a)
case <child>{contents @ _*}</child> =>
for (a <- contents) process(a)
case <grandchild>{contents @ _*}</grandchild> =>
for (a <- contents) process(a)
case _ => println(quot;leafquot;)
}
}
12. Concatenation
def add(p: Node, newEntry: Node ): Node =
p match {
case <div>{ ch @ _* }</div> =>
<div>{ ch }{ newEntry }</div>
}
17. val src =
scala.io.Source.fromString(quot;<root><child></child></root>quot;)
val er = new scala.xml.pull.XMLEventReader().initialize(src)
er.next
...
21. • ‘cloud’ web hosting environment on
google’s infrastructure
• uses non relational ‘bigtable’ for data
persistance
• user authentication uses google accounts
or openid
• also has email (sending), memcache and
image manipulation services
22. • working example:
• code: http://bitbucket.org/markryall/scalagae
• live: http://pairs.appspot.com
• use latest datanucleus enhancer from http://
www.datanucleus.org/downloads/maven2-
nightly/org/datanucleus/datanucleus-
enhancer/1.1.2/
26. var userService = UserServiceFactory.getUserService();
var user = userService.getCurrentUser();
if (user == null) {
response.sendRedirect(userService.createLoginURL(request.getRequestURI()))
return
}