[Yanel-commits] rev 22390 - in public/yanel/trunk/src/resources/directory: src/java/org/wyona/yanel/impl/resources xslt

josias at wyona.com josias at wyona.com
Fri Feb 2 15:28:26 CET 2007


Author: josias
Date: 2007-02-02 15:28:25 +0100 (Fri, 02 Feb 2007)
New Revision: 22390

Modified:
   public/yanel/trunk/src/resources/directory/src/java/org/wyona/yanel/impl/resources/DirectoryResource.java
   public/yanel/trunk/src/resources/directory/xslt/dir2xhtml.xsl
Log:
fixed problem with trailing slash, see bug #5160. thanks to simon

Modified: public/yanel/trunk/src/resources/directory/src/java/org/wyona/yanel/impl/resources/DirectoryResource.java
===================================================================
--- public/yanel/trunk/src/resources/directory/src/java/org/wyona/yanel/impl/resources/DirectoryResource.java	2007-02-02 14:14:52 UTC (rev 22389)
+++ public/yanel/trunk/src/resources/directory/src/java/org/wyona/yanel/impl/resources/DirectoryResource.java	2007-02-02 14:28:25 UTC (rev 22390)
@@ -134,19 +134,25 @@
         }
 
         try {
-            //Transformer transformer = TransformerFactory.newInstance().newTransformer(getXSLTStreamSource(getPath(), contentRepo));
+            String assetPath = "";
+            if (getPath().endsWith("/")) {
+                assetPath = "../";
+            }
             
             TransformerFactory tfactory = TransformerFactory.newInstance();
             String[] xsltTransformers = getXSLTprop();
             
             java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream();
             
-            
             Transformer transformerIntern = tfactory.newTransformer(getXSLTStreamSource( contentRepo));
             StreamSource orig = new StreamSource(new java.io.StringBufferInputStream(sb.toString()));
             
+            transformerIntern.setParameter("yanel.path.name", PathUtil.getName(getPath()));
+            transformerIntern.setParameter("yanel.path", getPath().toString());
+            transformerIntern.setParameter("yanel.back2context", backToRoot(getPath(), assetPath));
+            transformerIntern.setParameter("yarep.back2realm", backToRoot(getPath(), assetPath));
             transformerIntern.transform(orig, new StreamResult(baos));
-                
+            
             if (xsltTransformers != null) {
                 //StreamSource orig = new StreamSource(new java.io.StringBufferInputStream(sb.toString()));
                 for (int i = 0; i < xsltTransformers.length; i++) {
@@ -155,10 +161,9 @@
                     Transformer transformer = tfactory.newTransformer(new StreamSource(contentRepo.getInputStream(new org.wyona.yarep.core.Path(new Path(xsltTransformers[i]).toString()))));
                     transformer.setParameter("yanel.path.name", PathUtil.getName(getPath()));
                     transformer.setParameter("yanel.path", getPath().toString());
-                    transformer.setParameter("yanel.back2context", backToRoot(getPath(), ""));
-                    transformer.setParameter("yarep.back2realm", backToRoot(getPath(), "../"));
+                    transformer.setParameter("yanel.back2context", backToRoot(getPath(), assetPath));
+                    transformer.setParameter("yarep.back2realm", backToRoot(getPath(), assetPath));
                     transformer.transform(orig, new StreamResult(baos));
-                    
                 }
             }
             // TODO: Is this the best way to generate an InputStream from an OutputStream?

Modified: public/yanel/trunk/src/resources/directory/xslt/dir2xhtml.xsl
===================================================================
--- public/yanel/trunk/src/resources/directory/xslt/dir2xhtml.xsl	2007-02-02 14:14:52 UTC (rev 22389)
+++ public/yanel/trunk/src/resources/directory/xslt/dir2xhtml.xsl	2007-02-02 14:28:25 UTC (rev 22390)
@@ -13,6 +13,10 @@
 <!--
 <xsl:output method="html"/>
 -->
+<xsl:param name="yanel.path.name" select="'NAME_IS_NULL'"/>
+<xsl:param name="yanel.path" select="'PATH_IS_NULL'"/>
+<xsl:param name="yanel.back2context" select="'BACK2CONTEXT_IS_NULL'"/>
+<xsl:param name="yarep.back2realm" select="'BACK2REALM_IS_NULL'"/>
 
 <xsl:template match="/">
 <html xmlns="http://www.w3.org/1999/xhtml">
@@ -43,10 +47,10 @@
 </xsl:template>
 
 <xsl:template match="dir:directory">
-Collection: <a href="{@name}/" title="directory"><xsl:value-of select="@path"/>/</a><br/>
+Collection: <a href="{$yarep.back2realm}.{@path}/" title="directory"><xsl:value-of select="@name"/>/</a><br/>
 </xsl:template>
 
 <xsl:template match="dir:file">
-Resource: <a href="{@name}" title="file"><xsl:value-of select="@path"/></a><br/>
+Resource: <a href="{$yarep.back2realm}.{@path}" title="file"><xsl:value-of select="@name"/></a><br/>
 </xsl:template>
 </xsl:stylesheet>




More information about the Yanel-commits mailing list