[Yanel-commits] rev 27489 -
public/yanel/trunk/src/contributions/resources/contact-form/src/java/org/wyona/yanel/impl/resources
michi at wyona.com
michi at wyona.com
Thu Sep 20 10:30:23 CEST 2007
Author: michi
Date: 2007-09-20 10:30:22 +0200 (Thu, 20 Sep 2007)
New Revision: 27489
Modified:
public/yanel/trunk/src/contributions/resources/contact-form/src/java/org/wyona/yanel/impl/resources/ContactResource.java
Log:
get body XSLT
Modified: public/yanel/trunk/src/contributions/resources/contact-form/src/java/org/wyona/yanel/impl/resources/ContactResource.java
===================================================================
--- public/yanel/trunk/src/contributions/resources/contact-form/src/java/org/wyona/yanel/impl/resources/ContactResource.java 2007-09-20 08:27:27 UTC (rev 27488)
+++ public/yanel/trunk/src/contributions/resources/contact-form/src/java/org/wyona/yanel/impl/resources/ContactResource.java 2007-09-20 08:30:22 UTC (rev 27489)
@@ -139,7 +139,6 @@
log.debug("language param is empty or null : " + language);
language = defaultLanguage;
}
- File xslFile = org.wyona.commons.io.FileUtil.file(rtd.getConfigFile().getParentFile().getAbsolutePath(), "xslt" + File.separator + "contact-form.xsl");
File xmlFile = org.wyona.commons.io.FileUtil.file(rtd.getConfigFile().getParentFile().getAbsolutePath(), "xml" + File.separator + "contact-form.xml");
try {
@@ -148,17 +147,16 @@
CatalogResolver catalogResolver = new CatalogResolver();
xmlReader.setEntityResolver(catalogResolver);
- // create first xslt transformer:
+ // create Body xslt transformer:
SAXTransformerFactory tf = (SAXTransformerFactory)TransformerFactory.newInstance();
- //transformer = TransformerFactory.newInstance().newTransformer(new StreamSource(xslFile));
- TransformerHandler xsltHandler1 = tf.newTransformerHandler(new StreamSource(xslFile));
+ TransformerHandler xsltHandler1 = tf.newTransformerHandler(getBodyXSLTStreamSource());
Transformer transformer = xsltHandler1.getTransformer();
boolean submit = false;
Enumeration enumeration = request.getParameterNames();
while(enumeration.hasMoreElements()){
- if(enumeration.nextElement().toString().equals("submit"))
+ if(enumeration.nextElement().toString().equals("email"))
submit = true;
}
if(submit) {
@@ -356,14 +354,10 @@
return new YarepUtil().getRepositoryPath(new org.wyona.yarep.core.Path(
path.toString()), getRepositoryFactory());
}
-
/**
- *
+ * Get global XSLT
* @param path
- * @param repo
- * @return
- * @throws NoSuchNodeException
*/
private StreamSource getGlobalXSLTStreamSource(Path path) throws NoSuchNodeException, RepositoryException, Exception {
String xsltPath = getResourceConfigProperty("xslt");
@@ -377,6 +371,18 @@
}
/**
+ * Get body XSLT
+ */
+ private StreamSource getBodyXSLTStreamSource() throws NoSuchNodeException, RepositoryException, Exception {
+ String xsltPath = getResourceConfigProperty("xslt-body");
+ if (xsltPath != null) {
+ return new StreamSource(getRealm().getRepository().getNode(xsltPath).getInputStream());
+ } else {
+ return new StreamSource(org.wyona.commons.io.FileUtil.file(rtd.getConfigFile().getParentFile().getAbsolutePath(), "xslt" + File.separator + "contact-form.xsl"));
+ }
+ }
+
+ /**
* Get mime type
*/
private String getMimeType() throws Exception {
More information about the Yanel-commits
mailing list