Guest User

Untitled

a guest
May 7th, 2012
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. set 'port', 4999
  2.  
  3. // All three methods (RDFBuilder closure, construct, resolve) return
  4. // Jena models and can be further processed with Groovy SPARQL's Sparql class
  5. // link(String endpoint) returns the Sparql endpoint or you can instantiate new
  6. // ones. Jena+ ARQ will be on the classpath
  7.  
  8. get("/") {
  9. setHeader("Content-Type", "application/rdf+xml")
  10. rdf.xml {
  11. defaultNamespace "http://localhost:4999/test"
  12. namespace foaf:"http://xmlns.com/foaf/0.1"
  13.  
  14. subject("#clarkkent") {
  15. property "foaf:gender":"male"
  16. property "foaf:title":"Mr"
  17. property "foaf:givenname":"Clark"
  18. property "foaf:family_name":"Kent"
  19. }
  20. };return null; // using the builder already sends output
  21. // and lets you customize the serialization format
  22. }
  23.  
  24. get("/groovy") {
  25. link("http://dbpedia.org/sparql").construct("""
  26. CONSTRUCT {
  27. <http://dbpedia.org/resource/Groovy_%28programming_language%29> <http://dbpedia.org/ontology/abstract> ?b
  28. } wHERE {
  29. <http://dbpedia.org/resource/Groovy_%28programming_language%29> <http://dbpedia.org/ontology/abstract> ?b
  30. }
  31. """)
  32. }
  33.  
  34. get("/tim") {
  35. resolve('http://www.w3.org/People/Berners-Lee/card')
  36. }
Advertisement
Add Comment
Please, Sign In to add comment