cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robin Green" <gree...@hotmail.com>
Subject [PATCH] Fixing xsp:pi to generate root PIs, and to accept xsp:expr within xsp:pi
Date Wed, 05 Apr 2000 16:47:41 GMT
It looks like xsp:pi never worked correctly with Cocoon, because cocoon 
expects PIs to be at the top level yet xsp:pi didn't generate them like 
this. Also I have added the ability to accept xsp:expr inside a dynamically 
generated PI - which will hopefully solve Rich Powers' problem with 
dynamically-selectable stylesheets (on cocoon-users list) - and changed the 
note in the docs to note that you can now do this.


diff -u -r1.13 xsp-java.xsl
--- xml-cocoon/src/org/apache/cocoon/processor/xsp/xsp-java.xsl 2000/03/01 
16:13:47    1.13
+++ xml-cocoon/src/org/apache/cocoon/processor/xsp/xsp-java.xsl 2000/04/05 
15:33:06
@@ -182,10 +182,23 @@
   </xsl:template>

   <xsl:template match="xsp:pi">
-    xspCurrentNode.appendChild(
+    <!-- Appending to xspCurrentNode doesn't work for Cocoon PIs,
+       because Cocoon expects its PIs to be at the top level. -->
+    document.appendChild(
       document.createProcessingInstruction(
         "<xsl:value-of select="@target"/>",
-        "<xsl:value-of select="."/>"
+        <xsl:for-each select="xsp:text|xsp:expr">
+          <xsl:choose>
+            <xsl:when test="name(.) = 'xsp:text'">
+              "<xsl:value-of select="."/>"
+            </xsl:when>
+            <xsl:when test="name(.) = 'xsp:expr'">
+             String.valueOf(<xsl:value-of select="."/>)
+            </xsl:when>
+          </xsl:choose>
+         +
+        </xsl:for-each>
+        ""
       )
     );
   </xsl:template>


diff -u -r1.2 xspprocessor.xml
--- xml-cocoon/xdocs/xspprocessor.xml   2000/01/31 21:51:54     1.2
+++ xml-cocoon/xdocs/xspprocessor.xml   2000/04/05 15:37:52
@@ -1183,13 +1183,15 @@
           </p>

           <p>
-            <code>&lt;xsp:expr&gt;</code> is not yet
-            supported to provide a value for a processing
-            instruction's <em>data</em>. Only textual, constant
-            values are allowed:
+            <code>&lt;xsp:expr&gt;</code> is now supported within xsp:pi
-
+           for example:
           </p>

-          <source>&lt;xsp:pi 
name="cocoon-process"&gt;type="xslt"&lt;/xsp:pi&gt;</source>
+          <source>&lt;xsp:pi name="xml-stylesheet"&gt;
+  href="&lt;xsp:expr&gt;request.getQueryString()&lt;/xsp:expr&gt;"
+  type="text/xsl"
+&lt;/xsp:pi&gt;
+          </source>

           <p>
             In the future, <code>&lt;xsp:pi&gt;</code> may be

______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com


Mime
View raw message