haul 02/05/22 09:03:08
Modified: src/java/org/apache/cocoon/components/language/markup/xsp/java
util.xsl
Log:
added util:get-source and util:include-source tags
plus helper function in XSPUtil
Revision Changes Path
1.5 +38 -19
xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/xsp/java/util.xsl
Index: util.xsl
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/xsp/java/util.xsl,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- util.xsl 21 Feb 2002 03:36:09 -0000 1.4
+++ util.xsl 22 May 2002 16:03:08 -0000 1.5
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
-<!-- $Id: util.xsl,v 1.4 2002/02/21 03:36:09 vgritsenko Exp $-->
+<!-- $Id: util.xsl,v 1.5 2002/05/22 16:03:08 haul Exp $-->
<!--
============================================================================
@@ -57,7 +57,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]>Ricardo Rocha</a>
* @author ported by <a href="mailto:[EMAIL PROTECTED]>Berin Loritsch</a>
- * @version CVS $Revision: 1.4 $ $Date: 2002/02/21 03:36:09 $
+ * @version CVS $Revision: 1.5 $ $Date: 2002/05/22 16:03:08 $
-->
<xsl:stylesheet version="1.0"
@@ -65,6 +65,9 @@
xmlns:xsp="http://apache.org/xsp"
xmlns:util="http://apache.org/xsp/util/2.0"
>
+ <xsl:variable name="namespace-uri">http://apache.org/xsp/util/2.0</xsl:variable>
+ <xsl:include href="logicsheet-util.xsl"/>
+
<xsl:template match="xsp:page">
<xsp:page>
<xsl:apply-templates select="@*"/>
@@ -123,6 +126,39 @@
</xsl:template>
-->
+ <xsl:template match="util:get-source">
+ <xsl:variable name="source-uri">
+ <xsl:call-template name="get-string-parameter">
+ <xsl:with-param name="name">uri</xsl:with-param>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsp:expr>
+ XSPUtil.getSourceAsString(<xsl:copy-of select="$source-uri"/>,this.resolver)
+ </xsp:expr>
+ </xsl:template>
+
+ <xsl:template match="util:include-source">
+ <xsl:variable name="source-uri">
+ <xsl:call-template name="get-string-parameter">
+ <xsl:with-param name="name">uri</xsl:with-param>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsp:logic>
+ {
+ org.apache.cocoon.components.parser.Parser newParser = null;
+ try {
+ newParser = (org.apache.cocoon.components.parser.Parser)
this.manager.lookup(org.apache.cocoon.components.parser.Parser.ROLE);
+ XSPUtil.include(this.resolver.resolve(<xsl:copy-of
select="$source-uri"/>).getInputSource(), this.contentHandler, newParser);
+ } catch (Exception e) {
+ getLogger().error("Could not include source", e);
+ } finally {
+ if (newParser != null) this.manager.release((Component) newParser);
+ }
+ }
+ </xsp:logic>
+ </xsl:template>
+
+
<!-- Include URL contents as SAX -->
<xsl:template match="util:include-uri">
<xsl:variable name="href">
@@ -302,22 +338,5 @@
</xsp:expr>
</xsl:template>
- <!-- Standard Templates -->
- <xsl:template name="get-nested-content">
- <xsl:param name="content"/>
- <xsl:choose>
- <xsl:when test="$content/xsp:text">"<xsl:value-of
select="$content"/>"</xsl:when>
- <xsl:when test="$content/*">
- <xsl:apply-templates select="$content/*"/>
- </xsl:when>
- <xsl:otherwise>"<xsl:value-of select="$content"/>"</xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
- <xsl:template match="@*|*|text()|processing-instruction()">
- <xsl:copy>
- <xsl:apply-templates select="@*|*|text()|processing-instruction()"/>
- </xsl:copy>
- </xsl:template>
</xsl:stylesheet>
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]