changeset 34:27ea2c63a0ff

~ use uri query parameter instead of hard-coded string
author Denis Ah-Kang <denis@w3.org>
date Wed, 10 Aug 2011 14:30:52 +0200
parents c1a2f3e5d8a9
children be526f103e9c
files src/main/scala/Main.scala
diffstat 1 files changed, 14 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/scala/Main.scala	Wed Aug 10 14:18:32 2011 +0200
+++ b/src/main/scala/Main.scala	Wed Aug 10 14:30:52 2011 +0200
@@ -104,7 +104,8 @@
     val pubrules = unfiltered.filter.Planify {
       case Path(Seg("pubrules" :: Nil)) & Params(params) if params contains "uri" => {
 
-        val spec = "http://www.w3.org/TR/2004/WD-i18n-html-tech-char-20040509/"
+        //val spec = "http://www.w3.org/TR/2004/WD-i18n-html-tech-char-20040509/"
+        val spec = params("uri").head
 
         val xsltParams:Map[String, String] =
           Map(
@@ -146,14 +147,6 @@
         trans2.setParameter(new QName("", "", "display"), new XdmAtomicValue("all"))
         trans2.setParameter(new QName("", "", "recurse_auth"), new XdmAtomicValue("on"))
 
-        // xhtml | xsl2 -> result
-        // param: doc_uri
-        val doc:XdmNode =
-          proc.newDocumentBuilder().build(new StreamSource(new URL(spec).openStream()))
-        val xsl3:XdmDestination = new XdmDestination()
-
-
-
         new ResponseStreamer {
           def stream(os:OutputStream):Unit = {
             val out:Serializer = new Serializer()
@@ -162,20 +155,21 @@
             //out.setOutputProperty(Serializer.Property.MEDIA_TYPE, "text/html");
             //out.setOutputProperty(Serializer.Property.INDENT, "yes");
             trans1.setDestination(trans2)
-
+            val xsl3:XdmDestination = new XdmDestination()
             trans2.setDestination(xsl3)
-
-
-
             trans1.transform()
-        val exp3:XsltExecutable = comp.compile(xsl3.getXdmNode().asSource())
-        val trans3:XsltTransformer = exp3.load()
-        trans3.setInitialContextNode(doc)
-        trans3.setParameter(new QName("", "", "doc_uri"), new XdmAtomicValue(spec))
-        xsltParams foreach { case (k, v) => trans3.setParameter(new QName("", "", k), new XdmAtomicValue(v))}
+
+            // xhtml | xsl2 -> result
+            // param: doc_uri
+            val exp3:XsltExecutable = comp.compile(xsl3.getXdmNode().asSource())
+            val trans3:XsltTransformer = exp3.load()
+            val doc:XdmNode =
+              proc.newDocumentBuilder().build(new StreamSource(new URL(spec).openStream()))
+            trans3.setInitialContextNode(doc)
+            trans3.setParameter(new QName("", "", "doc_uri"), new XdmAtomicValue(spec))
+            xsltParams foreach { case (k, v) => trans3.setParameter(new QName("", "", k), new XdmAtomicValue(v))}
             trans3.setDestination(out)
-        
-        trans3.transform()
+            trans3.transform()
 
           }
         }
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.