- fix error in namespaces in get company footer

- add a very demoware ready sample multi channel output, meaning generating a really ugly plain text version of the press release and adding a link to it from the html version.
- removing the company footer xsl as it is no longer mandatory to have one
- passing more parameters to the xsl process - rather ugly implementation - needs to be revisited



git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@4044 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Ariel Backenroth
2006-10-06 04:00:21 +00:00
parent d26fe8cbb5
commit d465973b34
7 changed files with 42 additions and 23 deletions

View File

@@ -18,6 +18,8 @@ package org.alfresco.web.templating;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.util.HashMap;
import java.util.Map;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.avm.AVMNodeConverter;
@@ -71,7 +73,10 @@ public class OutputUtil
LOGGER.debug("Created file node for file: " +
fullAvmPath);
final OutputStreamWriter out = new OutputStreamWriter(fileOut);
tom.generate(xml, tt, sandBoxUrl, out);
final HashMap<String, String> parameters =
getOutputMethodParameters(sandBoxUrl, fileName, generatedFileName);
tom.generate(xml, tt, parameters, out);
out.close();
NodeRef outputNodeRef = AVMNodeConverter.ToNodeRef(-1, fullAvmPath);
@@ -136,7 +141,9 @@ public class OutputUtil
}
final OutputStreamWriter writer = new OutputStreamWriter(out);
tom.generate(xml, tt, sandBoxUrl, writer);
final HashMap<String, String> parameters =
getOutputMethodParameters(sandBoxUrl, fileName, generatedFileName);
tom.generate(xml, tt, parameters, writer);
writer.close();
LOGGER.debug("generated " + fileName + " using " + tom);
}
@@ -148,4 +155,15 @@ public class OutputUtil
throw e;
}
}
private static HashMap<String, String> getOutputMethodParameters(final String sandBoxUrl,
final String fileName,
final String generatedFileName)
{
final HashMap<String, String> parameters = new HashMap<String, String>();
parameters.put("avm_store_url", sandBoxUrl);
parameters.put("derived_from_file_name", fileName);
parameters.put("generated_file_name", generatedFileName);
return parameters;
}
}

View File

@@ -18,6 +18,7 @@ package org.alfresco.web.templating;
import java.io.Serializable;
import java.io.Writer;
import java.util.Map;
import org.w3c.dom.Document;
/**
@@ -37,7 +38,7 @@ public interface TemplateOutputMethod
*/
public void generate(final Document xmlContent,
final TemplateType tt,
final String sandBoxUrl,
final Map<String, String> parameters,
final Writer out)
throws Exception;

View File

@@ -17,6 +17,7 @@
package org.alfresco.web.templating.xforms;
import java.io.*;
import java.util.Map;
import org.alfresco.web.templating.*;
import org.chiba.xml.util.DOMUtil;
@@ -33,7 +34,7 @@ public class FreeMarkerOutputMethod
public void generate(final Document xmlContent,
final TemplateType tt,
final String sandBoxUrl,
final Map<String, String> parameters,
final Writer out)
{
}

View File

@@ -43,6 +43,7 @@ import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.xml.sax.SAXException;
import org.alfresco.service.cmr.repository.NodeRef;
import java.util.Map;
public class XSLTOutputMethod
implements TemplateOutputMethod
@@ -62,7 +63,7 @@ public class XSLTOutputMethod
public void generate(final Document xmlContent,
final TemplateType tt,
final String sandBoxUrl,
final Map<String, String> parameters,
final Writer out)
throws ParserConfigurationException,
TransformerConfigurationException,
@@ -70,6 +71,8 @@ public class XSLTOutputMethod
SAXException,
IOException
{
// XXXarielb - dirty - fix this
final String sandBoxUrl = (String)parameters.get("avm_store_url");
final TransformerFactory tf = TransformerFactory.newInstance();
final TemplatingService ts = TemplatingService.getInstance();
final DOMSource source = new DOMSource(ts.parseXML(this.nodeRef));
@@ -103,7 +106,12 @@ public class XSLTOutputMethod
}
}
});
t.setParameter("avm_store_url", sandBoxUrl);
for (Map.Entry<String, String> e : parameters.entrySet())
{
t.setParameter(e.getKey(), e.getValue());
}
LOGGER.debug("setting parameter avm_store_url=" + sandBoxUrl);
final StreamResult result = new StreamResult(out);
try

View File

@@ -1,12 +1,12 @@
<jsp:root version="1.2"
xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:alfresco="http://www.alfresco.org/alfresco"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:pr="http://www.alfresco.org/pr">
<jsp:directive.page language="java" contentType="text/html; charset=UTF-8"/>
<jsp:directive.page isELIgnored="false"/>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
xmlns:alfresco="http://www.alfresco.org/alfresco"
elementFormDefault="qualified">
<xs:simpleType name="company-footer">
<xs:restriction base="xs:string">
<c:forEach items="${pr:getCompanyFooters(pageContext)}" var="companyFooter">

View File

@@ -1,15 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:alfresco="http://www.alfresco.org/alfresco"
exclude-result-prefixes="xhtml">
<xsl:output method="html" version="4.01" encoding="UTF-8" indent="yes"
doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
<xsl:preserve-space elements="*"/>
<xsl:template match="/">
this template produces no output. the xml is used by press-release.xsl
</xsl:template>
</xsl:stylesheet>

View File

@@ -3,6 +3,7 @@
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:alfresco="http://www.alfresco.org/alfresco"
xmlns:fn="http://www.w3.org/2005/02/xpath-functions"
exclude-result-prefixes="xhtml">
<xsl:output method="html" encoding="UTF-8" indent="yes"
doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
@@ -10,6 +11,7 @@
<xsl:preserve-space elements="*"/>
<xsl:param name="avm_store_url" select="'not_specified'"/>
<xsl:param name="derived_from_file_name" select="'not_specified'"/>
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
@@ -98,6 +100,10 @@
<div><p>Chuck Tanowitz<br />Schwartz Communications<br />+1 781 684-0770<br />alfresco@schwartz-pr.com</p></div>
</xsl:if>
<!-- END MAIN CONTENT -->
<xsl:element name="a">
<xsl:attribute name="href"><xsl:value-of select="fn:replaceAll($derived_from_file_name, '.xml', '.txt')"/></xsl:attribute>
<xsl:text>view plain text version</xsl:text>
</xsl:element>
</div>
<!-- Feature Content -->
<div id="right_content">&#160;</div>