dims 01/06/11 03:51:20
Modified: src/org/apache/cocoon/components/language/markup/sitemap/java
sitemap.xsl
Log:
Patch for using SAXON instead of Xalan
from Ovidiu Predescu <[EMAIL PROTECTED]>
Revision Changes Path
1.14 +57 -52
xml-cocoon2/src/org/apache/cocoon/components/language/markup/sitemap/java/sitemap.xsl
Index: sitemap.xsl
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/components/language/markup/sitemap/java/sitemap.xsl,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- sitemap.xsl 2001/06/08 20:28:15 1.13
+++ sitemap.xsl 2001/06/11 10:51:17 1.14
@@ -13,7 +13,7 @@
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:map="http://apache.org/cocoon/sitemap/1.0"
-
xmlns:java="http://xml.apache.org/xslt/java/org.apache.cocoon.sitemap.XSLTFactoryLoader"
exclude-result-prefixes="java"
+ xmlns:XSLTFactoryLoader="org.apache.cocoon.sitemap.XSLTFactoryLoader"
version="1.0">
<xsl:output method="text"/>
@@ -26,13 +26,39 @@
<xsl:variable name="nsprefix">map</xsl:variable>
- <!-- this variable holds the factory loader used to get at the code
matcher/selector factories
- are producing
- FIXME(GP): This approach seem Xalan dependant and not (yet) portable
- -->
- <xsl:variable name="factory-loader" select="java:new()"/>
+ <!--
+ this variable holds the factory loader used to get at the code
+ matcher/selector factories are producing
+ ovidiu: use the class name as the namespace to identify the
+ class. This is supposedly portable across XSLT implementations.
+ -->
+ <xsl:variable
+ name="factory-loader"
+ select="XSLTFactoryLoader:new()"
+ xmlns:XSLTFactoryLoader="org.apache.cocoon.sitemap.XSLTFactoryLoader"/>
+
+ <!-- Define the XSLT processor. Currently only Saxon and Xalan are
+ recognized. -->
+ <xsl:variable name="xslt-processor">
+ <xsl:choose>
+ <xsl:when test="contains(system-property('xsl:vendor-url'),
'xalan')">xalan</xsl:when>
+ <xsl:when test="contains(system-property('xsl:vendor-url'),
'saxon')">saxon</xsl:when>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:template name="line-number">
+ <xsl:choose>
+ <xsl:when test="$xslt-processor = 'saxon'"
+ xmlns:saxon="http://icl.com/saxon">
+//file <xsl:value-of select="saxon:system-id()"/>
+//line <xsl:value-of select="saxon:line-number()"/>
+</xsl:when>
+ <xsl:otherwise>
+//line numbers not supported with <xsl:value-of select="$xslt-processor"/>
+</xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
<!-- this template wraps the hole content within a single <code> element which
the xsp core logicsheet uses to build the java source code out of it
-->
@@ -101,7 +127,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
- * @version CVS $Id: sitemap.xsl,v 1.13 2001/06/08 20:28:15 giacomo Exp $
+ * @version CVS $Id: sitemap.xsl,v 1.14 2001/06/11 10:51:17 dims Exp $
*/
public class <xsl:value-of select="@file-name"/> extends AbstractSitemap {
static final String LOCATION = "<xsl:value-of select="translate(@file-path,
'/', '.')"/>.<xsl:value-of select="@file-name"/>";
@@ -116,18 +142,20 @@
<!-- Generate matchers which implements CodeFactory -->
<xsl:for-each select="/map:sitemap/map:components/map:matchers/map:matcher">
+<xsl:call-template name="line-number"/>
<xsl:variable name="src">
<xsl:value-of select="@src"/>
</xsl:variable>
- <xsl:if test="java:isFactory($factory-loader, string($src))">
+ <xsl:if test="XSLTFactoryLoader:isFactory($factory-loader, string($src))">
<xsl:variable name="type" select="translate(@name, '- ', '__')"/>
<xsl:variable name="default" select="$type = ../@default"/>
<xsl:variable name="config"><xsl:copy-of select="."/></xsl:variable>
- private Map <xsl:value-of select="$type"/>Match (<xsl:value-of
select="java:getParameterSource($factory-loader, string($src),$config)"/> pattern, Map
objectModel, Parameters parameters) {
- <xsl:value-of select="java:getMethodSource($factory-loader,
string($src),$config)"/>
+ private Map <xsl:value-of select="$type"/>Match (<xsl:value-of
select="XSLTFactoryLoader:getParameterSource($factory-loader, string($src),$config)"/>
pattern, Map objectModel, Parameters parameters) {
+ <xsl:value-of
select="XSLTFactoryLoader:getMethodSource($factory-loader, string($src),$config)"/>
}
<!-- process all map:match elements with a type attribute refering to the
current matcher factory iteration -->
<xsl:for-each
select="/map:sitemap/map:pipelines/map:pipeline/descendant-or-self::map:match[@type=$type
or (not(@type) and $default)]">
+<xsl:call-template name="line-number"/>
<xsl:variable name="matcher-name">
<xsl:call-template name="generate-name">
<xsl:with-param name="prefix">matcher_</xsl:with-param>
@@ -135,7 +163,7 @@
</xsl:call-template>
</xsl:variable>
// The generated matcher for a pattern of "<xsl:value-of
select="@pattern"/>"
- <xsl:value-of
select="java:getClassSource($factory-loader,string($src),string($matcher-name),string(@pattern),$config)"/>
+ <xsl:value-of
select="XSLTFactoryLoader:getClassSource($factory-loader,string($src),string($matcher-name),string(@pattern),$config)"/>
</xsl:for-each>
</xsl:if>
</xsl:for-each>
@@ -143,18 +171,20 @@
<!-- Generate selectors which implements CodeFactory -->
<xsl:for-each select="/map:sitemap/map:components/map:selectors/map:selector">
+<xsl:call-template name="line-number"/>
<xsl:variable name="src">
<xsl:value-of select="@src"/>
</xsl:variable>
- <xsl:if test="java:isFactory($factory-loader, string($src))">
+ <xsl:if test="XSLTFactoryLoader:isFactory($factory-loader, string($src))">
<xsl:variable name="name" select="@name"/>
<xsl:variable name="type" select="translate(@name, '- ', '__')"/>
<xsl:variable name="default" select="@name = ../@default"/>
<xsl:variable name="config" select="descendant-or-self::*"/>
- private boolean <xsl:value-of select="$name"/>Select (<xsl:value-of
select="java:getParameterSource($factory-loader, string($src),$config)"/> pattern, Map
objectModel, Parameters param) {
- <xsl:value-of select="java:getMethodSource($factory-loader,
string($src),$config)"/>
+ private boolean <xsl:value-of select="$name"/>Select (<xsl:value-of
select="XSLTFactoryLoader:getParameterSource($factory-loader, string($src),$config)"/>
pattern, Map objectModel, Parameters param) {
+ <xsl:value-of
select="XSLTFactoryLoader:getMethodSource($factory-loader, string($src),$config)"/>
}
<xsl:for-each
select="/map:sitemap/map:pipelines/map:pipeline/descendant::map:select[@type=$name or
(not(@type) and $default)]/map:when">
+<xsl:call-template name="line-number"/>
<xsl:variable name="selector-name">
<xsl:call-template name="generate-name">
<xsl:with-param name="prefix">selector_</xsl:with-param>
@@ -162,7 +192,7 @@
</xsl:call-template>
</xsl:variable>
<!-- produce a definition for this test string -->
- <xsl:value-of
select="java:getClassSource($factory-loader,string($src),string($selector-name),string(@test),$config)"/>
+ <xsl:value-of
select="XSLTFactoryLoader:getClassSource($factory-loader,string($src),string($selector-name),string(@test),$config)"/>
</xsl:for-each>
</xsl:if>
</xsl:for-each>
@@ -277,6 +307,7 @@
<!-- generate methods for every map:resource element -->
<xsl:for-each select="/map:sitemap/map:resources/map:resource">
+<xsl:call-template name="line-number"/>
/**
* This is the internal resource named "<xsl:value-of select="@name"/>"
* @param pipeline A <code>StreamPipeline</code> holding the
sitemap component collected so far
@@ -301,6 +332,7 @@
<!-- generate methods for every map:view element -->
<xsl:for-each select="/map:sitemap/map:views/map:view">
+<xsl:call-template name="line-number"/>
/**
* This is the method to produce the "<xsl:value-of select="@name"/>" view
of the requested resource
* @param pipeline A <code>StreamPipeline</code> holding the
sitemap component collected so far
@@ -323,6 +355,7 @@
<!-- generate methods for every map:action-set element -->
<xsl:for-each select="/map:sitemap/map:action-sets/map:action-set">
+<xsl:call-template name="line-number"/>
/**
* This is the method to process the "<xsl:value-of select="@name"/>"
action-set of the requested resource
* @param cocoon_action A <code>String</code> holding the
requested action
@@ -420,6 +453,7 @@
<!-- process the pipelines -->
<!-- for each pipeline element generate a try/catch block -->
<xsl:for-each select="/map:sitemap/map:pipelines/map:pipeline">
+<xsl:call-template name="line-number"/>
<xsl:variable name="pipeline-position" select="position()"/>
<xsl:if test="@internal-only = 'yes' or @internal-only='true'">
if (internalRequest) {
@@ -456,6 +490,7 @@
<!-- generate methods for every map:handle-errors elements in all
map:pipeline elements -->
<xsl:for-each select="/map:sitemap/map:pipelines/map:pipeline">
+<xsl:call-template name="line-number"/>
<xsl:variable name="pipeline-position" select="position()"/>
<xsl:if test="(./map:handle-errors)">
private boolean error_process_<xsl:value-of select="$pipeline-position"/>
(Environment environment, Map objectModel, Exception e, boolean internalRequest)
@@ -516,7 +551,7 @@
<!-- check if this matcher is a factory ? -->
<xsl:variable name="is-factory">
- <xsl:value-of select="java:isFactory($factory-loader,
string(/map:sitemap/map:components/map:matchers/map:matcher[@name=$matcher-type]/@src))"/>
+ <xsl:value-of select="XSLTFactoryLoader:isFactory($factory-loader,
string(/map:sitemap/map:components/map:matchers/map:matcher[@name=$matcher-type]/@src))"/>
</xsl:variable>
<!-- break on error when old parameter syntax exists -->
@@ -583,39 +618,6 @@
</xsl:call-template>
</xsl:variable>
- <!-- Modified 20010509 L.Sutic Changed to pass sitemap parameters. -->
-
- <!-- break on error when old parameter syntax exists -->
- <xsl:if test="parameter">
- <xsl:call-template name="error">
- <xsl:with-param name="message">Sitemap parameters should now be in the
sitemap namespace (map:parameter).</xsl:with-param>
- </xsl:call-template>
- </xsl:if>
-
- <!-- test if we have to define parameters for this action -->
- <xsl:if test="count(map:parameter)>0">
- param = new Parameters ();
- </xsl:if>
-
- <!-- generate the value used for the parameter argument in the invocation of
the act method of this action -->
- <xsl:variable name="component-param">
- <xsl:choose>
- <xsl:when test="count(map:parameter)>0">
- param
- </xsl:when>
- <xsl:otherwise>
- emptyParam
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <!-- collect the parameters -->
- <xsl:apply-templates select="map:parameter">
- <xsl:with-param name="param">param</xsl:with-param>
- </xsl:apply-templates>
-
- <!-- modification end -->
-
<!-- Modified 20010510 L.Sutic Changed to pass sitemap parameters. -->
<!-- break on error when old parameter syntax exists -->
@@ -649,9 +651,9 @@
<!-- modification end -->
-
<!-- loop through all the when cases -->
<xsl:for-each select="./map:when">
+<xsl:call-template name="line-number"/>
<!-- get the pattern used -->
<xsl:variable name="test-value">
@@ -672,7 +674,7 @@
<!-- check if this selector is a factory ? -->
<xsl:variable name="is-factory">
- <xsl:value-of select="java:isFactory($factory-loader,
string(/map:sitemap/map:components/map:selectors/map:selector[@name=$selector-type]/@src))"/>
+ <xsl:value-of select="XSLTFactoryLoader:isFactory($factory-loader,
string(/map:sitemap/map:components/map:selectors/map:selector[@name=$selector-type]/@src))"/>
</xsl:variable>
<!-- Modified 20010509 L.Sutic Changed to pass sitemap parameters. -->
@@ -701,6 +703,7 @@
<!-- this is the actual code produced on the otherwise element -->
<xsl:for-each select="./map:otherwise">
+<xsl:call-template name="line-number"/>
else {
getLogger().debug("Select Otherwise");
<xsl:apply-templates/>
@@ -1150,8 +1153,9 @@
<xsl:variable name="ns" select="namespace-uri(.)"/>
<xsl:for-each select="$components">
+<xsl:call-template name="line-number"/>
<xsl:variable name="is-factory-component"
- select="@src and ($name = 'matcher' or $name = 'selector') and
java:isFactory($factory-loader, string(@src))"/>
+ select="@src and ($name = 'matcher' or $name = 'selector') and
XSLTFactoryLoader:isFactory($factory-loader, string(@src))"/>
<xsl:if test="$is-factory-component=false()">
{
DefaultConfiguration cconf1 = new DefaultConfiguration("<xsl:value-of
select="translate(@name, '- ', '__')"/>", LOCATION);
@@ -1207,6 +1211,7 @@
<!-- process content -->
<xsl:for-each select="$components">
+<xsl:call-template name="line-number"/>
{
DefaultConfiguration cconf<xsl:value-of select="$level"/> = new
DefaultConfiguration("<xsl:value-of select="name(.)"/>", LOCATION);
<xsl:for-each select="attribute::*[name(.)!=$qname]">
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]