Josias Thoeny wrote:
On Fri, 2006-02-10 at 14:53 +0100, Josias Thoeny wrote:
On Fri, 2006-02-10 at 08:27 -0500, Doug Chestnut wrote:
Hi Josias,
Josias Thoeny wrote:
On Thu, 2006-02-09 at 21:56 +0000, [EMAIL PROTECTED] wrote:
Author: chestnut
Date: Thu Feb 9 13:56:04 2006
New Revision: 376448
URL: http://svn.apache.org/viewcvs?rev=376448&view=rev
Log:
removal of fallback:// from external relaxng schemas,
while still utilizing fallback functionality by specifying
the publication the schema is being used in
Hi Doug,
Thanks for fixing this.
I just wanted to ask how this relates to the following pipeline in
global-sitemap.xmap:
<!-- RNG fallback requests -->
<map:match pattern="fallback/**.rng">
<map:generate src="fallback://{1}.rng"/>
<map:transform src="lenya/xslt/util/translate-rng-includes.xsl">
<map:parameter name="contextprefix"
value="{request:contextPath}"/>
</map:transform>
<map:serialize type="xml"/>
</map:match>
Is this pipeline now obsolete?
Yes, I think so, but I will do a search just to make sure it is still
being used, then remove.
It uses translate-rng-includes.xsl to replace the schema include. Is
this xsl still necessary now?
Same here. I will also take a look at translate-rng-includes.xsl to be
sure I have the logic correct in external-relax.xsl. While at it I will
rename to translate-rng-includes.xsl since it is more descriptive.
This fallback/**.rng match wasn't working properly since the pubid
wasn't specified. The core rng was always used (by bxe). We could have
fixed this by just changing the match pattern to {pubid}/fallback/**.rng
but I figured that this was better handled by our new
modules-resources.xmap.
A few more comments:
I noticed that BXE is not saving properly. The cause seems to be the
following include in xhtml.rng:
<include href="fallback://lenya/resources/schemas/lenya.rng"/>
It gets transformed to
<include href="/default/modules//"/>
The rng-translating xsl probably should rewrite this href also, but how
to handle such fallback urls which don't belong to a module?
If fallback should work properly, the pubid should be used also, right?
So how should the url look like?
Maybe:
/pubid/fallback/resources/schemas/lenya.rng
After a second thought, I'd prefer to use only _one_ way to transform
fallback:// URIs into http:// URIs.
I agree ;).
Examples:
fallback://lenya/resources/schemas/lenya.rng
->
/context-prefix/pubid/fallback/lenya/resources/schemas/lenya.rng
fallback://lenya/modules/xhtml/resources/schemas/xhtml/xhtml-basic.rng
->
/context-prefix/pubid/fallback/lenya/modules/xhtml/resources/schemas/xhtml/xhtml-basic.rng
fallback://resources/shared/javascript/foo.js
->
/context-prefix/pubid/fallback/resources/shared/javascript/foo.js
Requests for resources already use fallback:// (or should).
Examples:
fallback//lenya/resources/schemas/lenya.rng
->
/context-prefix/pubid/lenya/schemas/lenya.rng
*since fallback should be enabled for all resource requests, it isn't
needed in the url
*since we only want to allow access to resources, it can be dropped as well
*core resources like /context-prefix/lenya/css/menu.css should be ->
/context-prefix/pubid/lenya/css/menu.css so publications can define
their own look and feel
*don't think this works now, but should?
fallback://lenya/modules/xhtml/resources/schemas/xhtml/xhtml-basic.rng
->
/context-prefix/pubid/modules/xhtml/schemas/xhtml-basic.rng
*access to module resources is the function of module-resources.xmap
*fallback is (or should be) supported in sitemap
fallback://resources/shared/javascript/foo.js
->
/context-prefix/pubid/area/javascript/foo.js
*access to pub shared resources is the function of resources-shared.xmap
*fallback is (or should be) supported in sitemap
I just don't think that we need to specify "fallback" for requests for
resources. I can't think of an instance when fallback wouldn't be desired.
WDYT?
--Doug
Or would the following solution be better:
If a requested RNG (or XSL) file contains an include using the
fallback:// protocol, resolve the URI and replace it by the actual URL
before sending the file to the client, instead of letting the client
request /fallback uris?
Perhaps this is what I am saying
Any opinions?
BTW, what is the "/lenya" for in fallback://lenya/something ?
Is it really necessary?
Josias
WDOT?
And another thing: The context prefix should be prepended to the url, as
it was done in translate-rng-includes.xsl.
Otherwise it won't work in tomcat, when Lenya is deployed in /lenya.
Josias
Thanks for keeping watch,
--Doug
Josias
Added:
lenya/trunk/src/webapp/lenya/xslt/resources/external-relax.xsl (with props)
Modified:
lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/ResourceTypeModule.java
lenya/trunk/src/webapp/lenya/module-resources.xmap
Modified:
lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/ResourceTypeModule.java
URL:
http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/ResourceTypeModule.java?rev=376448&r1=376447&r2=376448&view=diff
==============================================================================
---
lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/ResourceTypeModule.java
(original)
+++
lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/ResourceTypeModule.java
Thu Feb 9 13:56:04 2006
@@ -27,6 +27,7 @@
import org.apache.cocoon.components.modules.input.AbstractInputModule;
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.Request;
+import org.apache.lenya.cms.publication.Publication;
import org.apache.lenya.cms.publication.Document;
import org.apache.lenya.cms.publication.DocumentIdentityMap;
import org.apache.lenya.cms.publication.ResourceType;
@@ -57,6 +58,7 @@
Session session = RepositoryUtil.getSession(request, getLogger());
ResourceType resourceType;
+ Publication pub = null;
String attribute;
String[] steps = name.split(":");
@@ -68,6 +70,7 @@
String webappUrl = ServletHelper.getWebappURI(request);
Document document = docFactory.getFromURL(webappUrl);
resourceType = document.getResourceType();
+ pub = document.getPublication();
} else {
attribute = steps[1];
String resourceTypeName = steps[0];
@@ -89,8 +92,8 @@
value = resourceType.getSchema().getURI();
} else if (attribute.equals(HTTP_SCHEMA_URI)) {
String uri = resourceType.getSchema().getURI();
- String path = uri.substring("fallback://".length());
- value = request.getContextPath() + "/fallback/" + path;
+ String path = uri.substring(uri.indexOf("/schemas"));
+ value = request.getContextPath() + "/" + pub.getId() +
"/modules/" + resourceType.getName() + path;
} else {
throw new ConfigurationException("Attribute [" + name + "] not
supported!");
}
Modified: lenya/trunk/src/webapp/lenya/module-resources.xmap
URL:
http://svn.apache.org/viewcvs/lenya/trunk/src/webapp/lenya/module-resources.xmap?rev=376448&r1=376447&r2=376448&view=diff
==============================================================================
--- lenya/trunk/src/webapp/lenya/module-resources.xmap (original)
+++ lenya/trunk/src/webapp/lenya/module-resources.xmap Thu Feb 9 13:56:04 2006
@@ -20,6 +20,13 @@
<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
<map:pipelines>
+ <map:pipeline internal-only="true">
+ <map:match pattern="*/**.*">
+ <map:match type="regexp" pattern="(.*\.)(rng)$">
+ <map:read src="fallback://lenya/modules/{../1}/resources/{../2}.{../3}" mime-type="application/xml"/>
+ </map:match>
+ </map:match>
+ </map:pipeline>
<map:pipeline>
<!-- matches modules/*/**.css -->
@@ -49,9 +56,13 @@
<map:match type="regexp" pattern="(.*\.)(xml)$">
<map:read src="fallback://lenya/modules/{../1}/resources/{../2}.{../3}" mime-type="text/xml"/>
</map:match>
- <map:match type="regexp" pattern="(.*\.)(rng)$">
- <map:read src="fallback://lenya/modules/{../1}/resources/{../2}.{../3}" mime-type="application/xml"/>
- </map:match>
+ <map:match type="regexp" pattern="(.*\.)(rng)$">
+ <map:generate
src="fallback://lenya/modules/{../1}/resources/{../2}.{../3}"/>
+ <map:transform
src="fallback://lenya/xslt/resources/external-relax.xsl">
+ <map:parameter name="publicationid"
value="{page-envelope:publication-id}"/>
+ </map:transform>
+ <map:serialize type="xml"/>
+ </map:match>
<map:match type="regexp" pattern="(.*\.)(jpg|JPG|Jpg|jpeg|Jpeg|JPEG)$">
<map:read src="fallback://lenya/modules/{../1}/resources/{../2}.{../3}" mime-type="image/jpeg" />
</map:match>
Added: lenya/trunk/src/webapp/lenya/xslt/resources/external-relax.xsl
URL:
http://svn.apache.org/viewcvs/lenya/trunk/src/webapp/lenya/xslt/resources/external-relax.xsl?rev=376448&view=auto
==============================================================================
--- lenya/trunk/src/webapp/lenya/xslt/resources/external-relax.xsl (added)
+++ lenya/trunk/src/webapp/lenya/xslt/resources/external-relax.xsl Thu Feb 9
13:56:04 2006
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ Copyright 1999-2004 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ >
+
+ <xsl:param name="publicationid" />
+
+
+ <xsl:template match="@href[starts-with(.,'fallback')]">
+ <xsl:variable name="nofallback"
select="substring-after(.,'fallback://lenya/modules/')"/>
+ <xsl:variable name="restype"
select="substring-before($nofallback,'/resources')"/>
+ <xsl:variable name="resource"
select="substring-after($nofallback,'resources/')"/>
+ <xsl:attribute name="href">
+ <xsl:value-of select="concat('/' , $publicationid, '/modules/' , $restype, '/',
$resource)"/>
+ </xsl:attribute>
+ </xsl:template>
+
+ <xsl:template match="@*|node()">
+ <xsl:copy>
+ <xsl:apply-templates select="@*|node()"/>
+ </xsl:copy>
+ </xsl:template>
+
+</xsl:stylesheet>
Propchange: lenya/trunk/src/webapp/lenya/xslt/resources/external-relax.xsl
------------------------------------------------------------------------------
svn:eol-style = native
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]