changeset 32:25e927e9ca98

~ first attempt to embed the pubrules checker
author Alexandre Bertails <bertails@w3.org>
date Tue, 09 Aug 2011 16:58:47 -0400
parents 5cea090725d9
children c1a2f3e5d8a9
files src/main/scala/Main.scala
diffstat 1 files changed, 55 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/scala/Main.scala	Tue Aug 09 13:50:55 2011 -0400
+++ b/src/main/scala/Main.scala	Tue Aug 09 16:58:47 2011 -0400
@@ -103,14 +103,66 @@
 
     val pubrules = unfiltered.filter.Planify {
       case Path(Seg("pubrules" :: Nil)) & Params(params) if params contains "uri" => {
+
+        val spec = "http://www.w3.org/TR/2011/WD-turtle-20110809/Overview.html"
+
         val xsltParams:Map[String, String] =
           Map(
             "uimode" -> "checker_full",
             "docstatus" -> "ord-wd-tr",
-            "uri" -> "http://www.w3.org/TR/2011/CR-WOFF-20110804/"
-          ) ++ ( params map { case(k, v) => (k, v.head) } )
+            "year" -> "2011",
+            "rectrack" -> "yes",
+            "prevrec" -> "none",
+            "patpol" -> "w3c",
+            "normative" -> "yes",
+            "filterValues" -> "",
+            "nscheckmanual" -> "",
+            "display" -> "all",
+            "recursive" -> "off",
+            "recurse_auth" -> "on") // ++ ( params map { case(k, v) => (k, v.head) } )
+        // 13-pubrules-src.html | 13-pubrules.xsl -> xsl1
+        // param: uri
+
+        val proc:Processor = new Processor(false)
+        val comp:XsltCompiler = proc.newXsltCompiler()
+        
+        val xsl1 = "http://www.w3.org/2005/07/13-pubrules.xsl"
+        val xslt1StreamSource = new StreamSource(new URL(xsl1).openStream())
+        xslt1StreamSource.setSystemId(xsl1)
+        val exp1:XsltExecutable = comp.compile(xslt1StreamSource)
+        val source1:XdmNode =
+          proc.newDocumentBuilder().build(new StreamSource(new URL("http://www.w3.org/2005/07/13-pubrules-src.html").openStream()))
+        val trans1:XsltTransformer = exp1.load()
+        trans1.setInitialContextNode(source1)
+        trans1.setParameter(new QName("", "", "uri"), new XdmAtomicValue(spec))
+
+        // xsl1 | frame.xsl -> xsl2
+        val frame = "http://www.w3.org/2005/09/checker/frame.xsl"
+        val xslt2StreamSource = new StreamSource(new URL(frame).openStream())
+        xslt2StreamSource.setSystemId(frame)
+        val exp2:XsltExecutable = comp.compile(xslt2StreamSource)
+        val trans2:XsltTransformer = exp2.load()
+
+        trans1.setDestination(trans2)
+        
+        // xhtml | xsl2 -> result
+        // param: doc_uri
+        val doc:XdmNode =
+          proc.newDocumentBuilder().build(new StreamSource(new URL(spec).openStream()))
+        trans2.setInitialContextNode(doc)
+        trans2.setParameter(new QName("", "", "doc_uri"), new XdmAtomicValue(spec))
+
+        new ResponseStreamer {
+          def stream(os:OutputStream):Unit = {
+            val out:Serializer = new Serializer()
+            out.setOutputStream(os)
+            trans2.setDestination(out)
+            trans2.transform()
+          }
+        }
+
         //val url = params("url").head
-        pubrulesXSLT(new URL("http://www.w3.org/2005/07/13-pubrules-src.html"), xsltParams)
+//        pubrulesXSLT(new URL("http://www.w3.org/2005/07/13-pubrules-src.html"), xsltParams)
       }
     }
 
Set up and maintained by W3C Systems Team, please report bugs to sysreq@w3.org.

W3C would like to thank Microsoft who donated the server that allows us to run this service.