Merged HEAD-QA to HEAD (4.2) (including moving test classes into separate folders)

51903 to 54309 


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@54310 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Samuel Langlois
2013-08-20 17:17:31 +00:00
parent 0a36e2af67
commit ab4ca7177f
1576 changed files with 36419 additions and 8603 deletions

View File

@@ -1,101 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.template;
import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import junit.framework.TestCase;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.ApplicationContextHelper;
import org.springframework.context.ApplicationContext;
/**
* @author Dmitry Velichkevich
*/
public class AVMTemplateNodeTest extends TestCase
{
private static final String TEST_WCM_NAMESPACE = "http://www.alfresco.org/model/testwcmmodel/1.0";
private static final QName ASPECT_AUTHORED = QName.createQName(TEST_WCM_NAMESPACE, "authored");
private static final QName PROP_AUTHORED_DATE = QName.createQName(TEST_WCM_NAMESPACE, "dateAuthored");
private static final ApplicationContext APPLICATION_CONTEXT = ApplicationContextHelper.getApplicationContext(new String[] { "classpath:alfresco/application-context.xml",
"classpath:test/alfresco/wcm-template-node-test-context.xml" });
private static final ServiceRegistry SERVICE_REGISTRY = (ServiceRegistry) APPLICATION_CONTEXT.getBean(ServiceRegistry.SERVICE_REGISTRY);
private AVMService avmService = SERVICE_REGISTRY.getAVMService();
@Override
protected void setUp() throws Exception
{
avmService.createStore("main");
avmService.createDirectory("main:/", "root");
avmService.createFile("main:/root", "testfile.txt");
}
@Override
protected void tearDown() throws Exception
{
avmService.purgeStore("main");
}
@SuppressWarnings("unchecked")
public void testDatePropertiesConversion() throws Exception
{
assertNotNull("Aspect 'twcm:authored' is not in the set of compiled dictionary models", SERVICE_REGISTRY.getDictionaryService().getAspect(ASPECT_AUTHORED));
List<Serializable> values = new LinkedList<Serializable>();
for (int i = 0; i < 5; i++)
{
values.add(new Date());
}
PropertyValue value = new PropertyValue(DataTypeDefinition.TEXT, (Serializable) values);
avmService.addAspect("main:/root/testfile.txt", ASPECT_AUTHORED);
avmService.setNodeProperty("main:/root/testfile.txt", PROP_AUTHORED_DATE, value);
NodeRef nodeRef = AVMNodeConverter.ToNodeRef(-1, "main:/root/testfile.txt");
AVMTemplateNode templateNode = new AVMTemplateNode(nodeRef, SERVICE_REGISTRY, null);
Map<String, Serializable> properties = templateNode.getProperties();
assertNotNull(properties);
assertFalse(properties.isEmpty());
assertTrue(properties.containsKey(PROP_AUTHORED_DATE));
Collection<Serializable> authoredDates = (Collection<Serializable>) properties.get(PROP_AUTHORED_DATE);
assertNotNull(authoredDates);
assertFalse(authoredDates.isEmpty());
for (Serializable date : authoredDates)
{
assertFalse(("Unexpected data type of 'twcm:authored' property values: " + ((null != date) ? (date.getClass().getName()) : ("null"))), date instanceof String);
}
}
}

View File

@@ -45,6 +45,7 @@ import freemarker.cache.MruCacheStorage;
import freemarker.cache.StringTemplateLoader;
import freemarker.core.Environment;
import freemarker.template.Configuration;
import freemarker.template.ObjectWrapper;
import freemarker.template.Template;
import freemarker.template.TemplateExceptionHandler;
@@ -81,6 +82,7 @@ public class FreeMarkerProcessor extends BaseProcessor implements TemplateProces
/** Template encoding */
private String defaultEncoding;
private ObjectWrapper qnameObjectWrapper = new QNameAwareObjectWrapper();
/** Enable/disable Freemarker's localized lookup feature*/
private boolean localizedLookup = DEFAULT_LOCALIZED_LOOKUP_VALUE;
@@ -122,7 +124,7 @@ public class FreeMarkerProcessor extends BaseProcessor implements TemplateProces
this.services.getNodeService(), this.services.getContentService(), defaultEncoding));
// use our custom object wrapper that can deal with QNameMap objects directly
config.setObjectWrapper(new QNameAwareObjectWrapper());
config.setObjectWrapper(qnameObjectWrapper);
// rethrow any exception so we can deal with them
config.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
@@ -162,7 +164,7 @@ public class FreeMarkerProcessor extends BaseProcessor implements TemplateProces
config.setTemplateLoader(stringTemplateLoader);
// use our custom object wrapper that can deal with QNameMap objects directly
config.setObjectWrapper(new QNameAwareObjectWrapper());
config.setObjectWrapper(qnameObjectWrapper);
// rethrow any exception so we can deal with them
config.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);

View File

@@ -1,131 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.template;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import junit.framework.TestCase;
import org.alfresco.repo.dictionary.DictionaryComponent;
import org.alfresco.repo.dictionary.DictionaryDAO;
import org.alfresco.repo.dictionary.M2Model;
import org.alfresco.repo.node.BaseNodeServiceTest;
import org.alfresco.repo.security.authentication.AuthenticationComponent;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.repository.TemplateService;
import org.alfresco.service.transaction.TransactionService;
import org.alfresco.util.ApplicationContextHelper;
import org.springframework.context.ApplicationContext;
/**
* @author Kevin Roast
*/
public class TemplateServiceImplTest extends TestCase
{
private static final String TEMPLATE_1 = "org/alfresco/repo/template/test_template1.ftl";
private static final ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
private TemplateService templateService;
private NodeService nodeService;
private TransactionService transactionService;
private ServiceRegistry serviceRegistry;
private AuthenticationComponent authenticationComponent;
/*
* @see junit.framework.TestCase#setUp()
*/
protected void setUp() throws Exception
{
super.setUp();
transactionService = (TransactionService)ctx.getBean("transactionComponent");
nodeService = (NodeService)ctx.getBean("nodeService");
templateService = (TemplateService)ctx.getBean("templateService");
serviceRegistry = (ServiceRegistry)ctx.getBean("ServiceRegistry");
this.authenticationComponent = (AuthenticationComponent)ctx.getBean("authenticationComponent");
this.authenticationComponent.setSystemUserAsCurrentUser();
DictionaryDAO dictionaryDao = (DictionaryDAO)ctx.getBean("dictionaryDAO");
// load the system model
ClassLoader cl = BaseNodeServiceTest.class.getClassLoader();
InputStream modelStream = cl.getResourceAsStream("alfresco/model/contentModel.xml");
assertNotNull(modelStream);
M2Model model = M2Model.createModel(modelStream);
dictionaryDao.putModel(model);
// load the test model
modelStream = cl.getResourceAsStream("org/alfresco/repo/node/BaseNodeServiceTest_model.xml");
assertNotNull(modelStream);
model = M2Model.createModel(modelStream);
dictionaryDao.putModel(model);
DictionaryComponent dictionary = new DictionaryComponent();
dictionary.setDictionaryDAO(dictionaryDao);
BaseNodeServiceTest.loadModel(ctx);
}
@Override
protected void tearDown() throws Exception
{
authenticationComponent.clearCurrentSecurityContext();
super.tearDown();
}
public void testTemplates()
{
transactionService.getRetryingTransactionHelper().doInTransaction(
new RetryingTransactionCallback<Object>()
{
@SuppressWarnings("unchecked")
public Object execute() throws Exception
{
StoreRef store = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "template_" + System.currentTimeMillis());
NodeRef root = nodeService.getRootNode(store);
BaseNodeServiceTest.buildNodeGraph(nodeService, root);
// check the default template engine exists
assertNotNull(templateService.getTemplateProcessor("freemarker"));
// create test model
Map model = new HashMap(7, 1.0f);
model.put("root", new TemplateNode(root, serviceRegistry, null));
// execute on test template
String output = templateService.processTemplate("freemarker", TEMPLATE_1, model);
// check template contains the expected output
assertTrue( (output.indexOf(root.getId()) != -1) );
System.out.print(output);
return null;
}
});
}
}

View File

@@ -27,7 +27,6 @@ import java.util.Set;
import org.alfresco.model.ContentModel;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.ContentData;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.version.Version;
import org.alfresco.service.cmr.version.VersionType;
@@ -184,19 +183,7 @@ public class VersionHistoryNode extends BaseContentNode implements NamespacePref
for (QName qname : props.keySet())
{
Serializable propValue = props.get(qname);
if (propValue instanceof NodeRef)
{
// NodeRef object properties are converted to new TemplateNode objects
// so they can be used as objects within a template
propValue = new TemplateNode(((NodeRef)propValue), parent.services, parent.imageResolver);
}
else if (propValue instanceof ContentData)
{
// ContentData object properties are converted to TemplateContentData objects
// so the content and other properties of those objects can be accessed
propValue = parent.new TemplateContentData((ContentData)propValue, qname);
}
Serializable propValue = parent.new TemplatePropertyConverter().convertProperty(props.get(qname), qname, parent.services, parent.imageResolver);
this.properties.put(qname.toString(), propValue);
}

View File

@@ -27,14 +27,11 @@ import java.util.Map;
import org.alfresco.model.ApplicationModel;
import org.alfresco.model.ContentModel;
import org.alfresco.model.WCMModel;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.repo.forms.processor.workflow.ExtendedFieldBuilder;
import org.alfresco.repo.workflow.WorkflowModel;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.avmsync.AVMDifference;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef;
@@ -47,7 +44,6 @@ import org.alfresco.service.namespace.NamespacePrefixResolver;
import org.alfresco.service.namespace.NamespacePrefixResolverProvider;
import org.alfresco.service.namespace.QName;
import org.alfresco.service.namespace.QNameMap;
import org.alfresco.service.namespace.RegexQNamePattern;
import org.alfresco.util.Pair;
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
* Copyright (C) 2005-2013 Alfresco Software Limited.
*
* This file is part of Alfresco
*
@@ -399,7 +399,8 @@ public class XSLTProcessor extends BaseProcessor implements TemplateProcessor
if (o instanceof String || o instanceof Number || o instanceof Boolean)
{
el.appendChild(xslTemplate.createTextNode(o.toString()));
docEl.insertBefore(el, docEl.getFirstChild());
// ALF-15413. Add the variables at the end of the list of children
docEl.insertBefore(el, null);
}
}
}

View File

@@ -1,336 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.template;
import java.io.StringWriter;
import java.util.Locale;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.rendition.executer.XSLTFunctions;
import org.alfresco.service.cmr.model.FileFolderService;
import org.alfresco.service.cmr.model.FileInfo;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.repository.TemplateProcessor;
import org.alfresco.service.cmr.repository.TemplateService;
import org.alfresco.service.cmr.search.ResultSet;
import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.util.BaseAlfrescoSpringTest;
import org.alfresco.util.GUID;
import org.alfresco.util.XMLUtil;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* @author Brian
*
*/
public class XSLTProcessorTest extends BaseAlfrescoSpringTest
{
private final static Log log = LogFactory.getLog(XSLTProcessorTest.class);
private XSLTFunctions xsltFunctions;
private SearchService searchService;
private NodeRef companyHome;
private FileFolderService fileFolderService;
private TemplateProcessor xsltProcessor;
private TemplateService templateService;
/*
* (non-Javadoc)
*
* @see org.alfresco.util.BaseAlfrescoSpringTest#onSetUpInTransaction()
*/
@SuppressWarnings("deprecation")
@Override
protected void onSetUpInTransaction() throws Exception
{
super.onSetUpInTransaction();
this.searchService = (SearchService) this.applicationContext.getBean("SearchService");
this.xsltFunctions = (XSLTFunctions) this.applicationContext.getBean("xsltFunctions");
this.nodeService = (NodeService) this.applicationContext.getBean("NodeService");
this.contentService = (ContentService) this.applicationContext.getBean("ContentService");
this.fileFolderService = (FileFolderService) this.applicationContext.getBean("FileFolderService");
this.xsltProcessor = (TemplateProcessor) this.applicationContext.getBean("xsltProcessor");
this.templateService = (TemplateService) this.applicationContext.getBean("TemplateService");
ResultSet rs = searchService.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, SearchService.LANGUAGE_XPATH,
"/app:company_home");
this.companyHome = rs.getNodeRef(0);
}
public void testSimplestStringTemplate() throws Exception
{
try
{
FileInfo file = createXmlFile(companyHome);
XSLTemplateModel model = new XSLTemplateModel();
model.put(XSLTProcessor.ROOT_NAMESPACE, XMLUtil.parse(file.getNodeRef(), contentService));
StringWriter writer = new StringWriter();
xsltProcessor.processString(verySimpleXSLT, model, writer);
String output = writer.toString();
log.debug("XSLT Processor output: " + output);
assertEquals("Avocado DipBagels, New York StyleBeef Frankfurter, Quarter PoundChicken Pot PieCole SlawEggsHazelnut SpreadPotato ChipsSoy Patties, GrilledTruffles, Dark Chocolate", output);
}
catch (Exception ex)
{
log.error("Error!", ex);
fail();
}
}
public void testSimplestNodeTemplate() throws Exception
{
try
{
FileInfo xmlFile = createXmlFile(companyHome);
FileInfo xslFile = createXmlFile(companyHome, verySimpleXSLT);
XSLTemplateModel model = new XSLTemplateModel();
model.put(XSLTProcessor.ROOT_NAMESPACE, XMLUtil.parse(xmlFile.getNodeRef(), contentService));
StringWriter writer = new StringWriter();
xsltProcessor.process(xslFile.getNodeRef().toString(), model, writer);
String output = writer.toString();
log.debug("XSLT Processor output: " + output);
assertEquals("Avocado DipBagels, New York StyleBeef Frankfurter, Quarter PoundChicken Pot PieCole SlawEggsHazelnut SpreadPotato ChipsSoy Patties, GrilledTruffles, Dark Chocolate", output);
}
catch (Exception ex)
{
log.error("Error!", ex);
fail();
}
}
public void testLocalisedNodeTemplate() throws Exception
{
// This should have the same result as testSimplestNodeTemplate as the localization should be ignored for node templates.
try
{
FileInfo xmlFile = createXmlFile(companyHome);
FileInfo xslFile = createXmlFile(companyHome, verySimpleXSLT);
XSLTemplateModel model = new XSLTemplateModel();
model.put(XSLTProcessor.ROOT_NAMESPACE, XMLUtil.parse(xmlFile.getNodeRef(), contentService));
StringWriter writer = new StringWriter();
xsltProcessor.process(xslFile.getNodeRef().toString(), model, writer, Locale.FRANCE);
String output = writer.toString();
log.debug("XSLT Processor output: " + output);
assertEquals("Avocado DipBagels, New York StyleBeef Frankfurter, Quarter PoundChicken Pot PieCole SlawEggsHazelnut SpreadPotato ChipsSoy Patties, GrilledTruffles, Dark Chocolate", output);
}
catch (Exception ex)
{
log.error("Error!", ex);
fail();
}
}
public void testSimplestClasspathTemplate() throws Exception
{
try
{
FileInfo xmlFile = createXmlFile(companyHome);
XSLTemplateModel model = new XSLTemplateModel();
model.put(XSLTProcessor.ROOT_NAMESPACE, XMLUtil.parse(xmlFile.getNodeRef(), contentService));
StringWriter writer = new StringWriter();
xsltProcessor.process("org/alfresco/repo/template/test_template1.xsl", model, writer);
String output = writer.toString();
log.debug("XSLT Processor output: " + output);
assertEquals("Avocado DipBagels, New York StyleBeef Frankfurter, Quarter PoundChicken Pot PieCole SlawEggsHazelnut SpreadPotato ChipsSoy Patties, GrilledTruffles, Dark Chocolate", output);
}
catch (Exception ex)
{
log.error("Error!", ex);
fail();
}
}
public void testLocalisedClasspathTemplate() throws Exception
{
try
{
FileInfo xmlFile = createXmlFile(companyHome);
XSLTemplateModel model = new XSLTemplateModel();
model.put(XSLTProcessor.ROOT_NAMESPACE, XMLUtil.parse(xmlFile.getNodeRef(), contentService));
StringWriter writer = new StringWriter();
xsltProcessor.process("org/alfresco/repo/template/test_template1.xsl", model, writer, new Locale("en", "AU"));
String output = writer.toString();
log.debug("XSLT Processor output: " + output);
assertEquals("G'day, Avocado DipBagels, New York StyleBeef Frankfurter, Quarter PoundChicken Pot PieCole SlawEggsHazelnut SpreadPotato ChipsSoy Patties, GrilledTruffles, Dark Chocolate", output);
writer = new StringWriter();
xsltProcessor.process("org/alfresco/repo/template/test_template1.xsl", model, writer, new Locale("en", "GB"));
output = writer.toString();
log.debug("XSLT Processor output: " + output);
assertEquals("Avocado DipBagels, New York StyleBeef Frankfurter, Quarter PoundChicken Pot PieCole SlawEggsHazelnut SpreadPotato ChipsSoy Patties, GrilledTruffles, Dark Chocolate", output);
writer = new StringWriter();
xsltProcessor.process("org/alfresco/repo/template/test_template1.xsl", model, writer, new Locale("fr", "FR"));
output = writer.toString();
log.debug("XSLT Processor output: " + output);
assertEquals("Bonjour, Avocado DipBagels, New York StyleBeef Frankfurter, Quarter PoundChicken Pot PieCole SlawEggsHazelnut SpreadPotato ChipsSoy Patties, GrilledTruffles, Dark Chocolate", output);
}
catch (Exception ex)
{
log.error("Error!", ex);
fail();
}
}
public void testTemplateServiceBinding() throws Exception
{
try
{
FileInfo xmlFile = createXmlFile(companyHome);
XSLTemplateModel model = new XSLTemplateModel();
model.put(XSLTProcessor.ROOT_NAMESPACE, XMLUtil.parse(xmlFile.getNodeRef(), contentService));
StringWriter writer = new StringWriter();
templateService.processTemplate("xslt", "org/alfresco/repo/template/test_template1.xsl", model, writer);
String output = writer.toString();
log.debug("XSLT Processor output: " + output);
assertEquals("Avocado DipBagels, New York StyleBeef Frankfurter, Quarter PoundChicken Pot PieCole SlawEggsHazelnut SpreadPotato ChipsSoy Patties, GrilledTruffles, Dark Chocolate", output);
}
catch (Exception ex)
{
log.error("Error!", ex);
fail();
}
}
private FileInfo createXmlFile(NodeRef folder)
{
return createXmlFile(folder, sampleXML);
}
private FileInfo createXmlFile(NodeRef folder, String content)
{
String name = GUID.generate();
FileInfo testXmlFile = fileFolderService.create(folder, name + ".xml", ContentModel.TYPE_CONTENT);
ContentWriter writer = contentService.getWriter(testXmlFile.getNodeRef(), ContentModel.PROP_CONTENT, true);
writer.setMimetype("text/xml");
writer.setEncoding("UTF-8");
writer.putContent(content);
return testXmlFile;
}
private String sampleXML = "<?xml version=\"1.0\"?>" + "<nutrition>" +
"<daily-values>" + "<total-fat units=\"g\">65</total-fat>" + "<saturated-fat units=\"g\">20</saturated-fat>"
+ "<cholesterol units=\"mg\">300</cholesterol>" + "<sodium units=\"mg\">2400</sodium>"
+ "<carb units=\"g\">300</carb>" + "<fiber units=\"g\">25</fiber>" + "<protein units=\"g\">50</protein>"
+ "</daily-values>" +
"<food>" + "<name>Avocado Dip</name>" + "<mfr>Sunnydale</mfr>" + "<serving units=\"g\">29</serving>"
+ "<calories total=\"110\" fat=\"100\"/>" + "<total-fat>11</total-fat>"
+ "<saturated-fat>3</saturated-fat>" + "<cholesterol>5</cholesterol>" + "<sodium>210</sodium>"
+ "<carb>2</carb>" + "<fiber>0</fiber>" + "<protein>1</protein>" + "<vitamins>" + "<a>0</a>" + "<c>0</c>"
+ "</vitamins>" + "<minerals>" + "<ca>0</ca>" + "<fe>0</fe>" + "</minerals>" + "</food>" +
"<food>" + "<name>Bagels, New York Style</name>" + "<mfr>Thompson</mfr>"
+ "<serving units=\"g\">104</serving>" + "<calories total=\"300\" fat=\"35\"/>"
+ "<total-fat>4</total-fat>" + "<saturated-fat>1</saturated-fat>" + "<cholesterol>0</cholesterol>"
+ "<sodium>510</sodium>" + "<carb>54</carb>" + "<fiber>3</fiber>" + "<protein>11</protein>" + "<vitamins>"
+ "<a>0</a>" + "<c>0</c>" + "</vitamins>" + "<minerals>" + "<ca>8</ca>" + "<fe>20</fe>" + "</minerals>"
+ "</food>" +
"<food>" + "<name>Beef Frankfurter, Quarter Pound</name>" + "<mfr>Armitage</mfr>"
+ "<serving units=\"g\">115</serving>" + "<calories total=\"370\" fat=\"290\"/>"
+ "<total-fat>32</total-fat>" + "<saturated-fat>15</saturated-fat>" + "<cholesterol>65</cholesterol>"
+ "<sodium>1100</sodium>" + "<carb>8</carb>" + "<fiber>0</fiber>" + "<protein>13</protein>" + "<vitamins>"
+ "<a>0</a>" + "<c>2</c>" + "</vitamins>" + "<minerals>" + "<ca>1</ca>" + "<fe>6</fe>" + "</minerals>"
+ "</food>" +
"<food>" + "<name>Chicken Pot Pie</name>" + "<mfr>Lakeson</mfr>" + "<serving units=\"g\">198</serving>"
+ "<calories total=\"410\" fat=\"200\"/>" + "<total-fat>22</total-fat>"
+ "<saturated-fat>9</saturated-fat>" + "<cholesterol>25</cholesterol>" + "<sodium>810</sodium>"
+ "<carb>42</carb>" + "<fiber>2</fiber>" + "<protein>10</protein>" + "<vitamins>" + "<a>20</a>"
+ "<c>2</c>" + "</vitamins>" + "<minerals>" + "<ca>2</ca>" + "<fe>10</fe>" + "</minerals>" + "</food>" +
"<food>" + "<name>Cole Slaw</name>" + "<mfr>Fresh Quick</mfr>" + "<serving units=\" cup\">1.5</serving>"
+ "<calories total=\"20\" fat=\"0\"/>" + "<total-fat>0</total-fat>" + "<saturated-fat>0</saturated-fat>"
+ "<cholesterol>0</cholesterol>" + "<sodium>15</sodium>" + "<carb>5</carb>" + "<fiber>2</fiber>"
+ "<protein>1</protein>" + "<vitamins>" + "<a>30</a>" + "<c>45</c>" + "</vitamins>" + "<minerals>"
+ "<ca>4</ca>" + "<fe>2</fe>" + "</minerals>" + "</food>" +
"<food>" + "<name>Eggs</name>" + "<mfr>Goodpath</mfr>" + "<serving units=\"g\">50</serving>"
+ "<calories total=\"70\" fat=\"40\"/>" + "<total-fat>4.5</total-fat>"
+ "<saturated-fat>1.5</saturated-fat>" + "<cholesterol>215</cholesterol>" + "<sodium>65</sodium>"
+ "<carb>1</carb>" + "<fiber>0</fiber>" + "<protein>6</protein>" + "<vitamins>" + "<a>6</a>" + "<c>0</c>"
+ "</vitamins>" + "<minerals>" + "<ca>2</ca>" + "<fe>4</fe>" + "</minerals>" + "</food>" +
"<food>" + "<name>Hazelnut Spread</name>" + "<mfr>Ferreira</mfr>" + "<serving units=\"tbsp\">2</serving>"
+ "<calories total=\"200\" fat=\"90\"/>" + "<total-fat>10</total-fat>" + "<saturated-fat>2</saturated-fat>"
+ "<cholesterol>0</cholesterol>" + "<sodium>20</sodium>" + "<carb>23</carb>" + "<fiber>2</fiber>"
+ "<protein>3</protein>" + "<vitamins>" + "<a>0</a>" + "<c>0</c>" + "</vitamins>" + "<minerals>"
+ "<ca>6</ca>" + "<fe>4</fe>" + "</minerals>" + "</food>" +
"<food>" + "<name>Potato Chips</name>" + "<mfr>Lees</mfr>" + "<serving units=\"g\">28</serving>"
+ "<calories total=\"150\" fat=\"90\"/>" + "<total-fat>10</total-fat>" + "<saturated-fat>3</saturated-fat>"
+ "<cholesterol>0</cholesterol>" + "<sodium>180</sodium>" + "<carb>15</carb>" + "<fiber>1</fiber>"
+ "<protein>2</protein>" + "<vitamins>" + "<a>0</a>" + "<c>10</c>" + "</vitamins>" + "<minerals>"
+ "<ca>0</ca>" + "<fe>0</fe>" + "</minerals>" + "</food>" +
"<food>" + "<name>Soy Patties, Grilled</name>" + "<mfr>Gardenproducts</mfr>"
+ "<serving units=\"g\">96</serving>" + "<calories total=\"160\" fat=\"45\"/>" + "<total-fat>5</total-fat>"
+ "<saturated-fat>0</saturated-fat>" + "<cholesterol>0</cholesterol>" + "<sodium>420</sodium>"
+ "<carb>10</carb>" + "<fiber>4</fiber>" + "<protein>9</protein>" + "<vitamins>" + "<a>0</a>" + "<c>0</c>"
+ "</vitamins>" + "<minerals>" + "<ca>0</ca>" + "<fe>0</fe>" + "</minerals>" + "</food>" +
"<food>" + "<name>Truffles, Dark Chocolate</name>" + "<mfr>Lyndon's</mfr>"
+ "<serving units=\"g\">39</serving>" + "<calories total=\"220\" fat=\"170\"/>"
+ "<total-fat>19</total-fat>" + "<saturated-fat>14</saturated-fat>" + "<cholesterol>25</cholesterol>"
+ "<sodium>10</sodium>" + "<carb>16</carb>" + "<fiber>1</fiber>" + "<protein>1</protein>" + "<vitamins>"
+ "<a>0</a>" + "<c>0</c>" + "</vitamins>" + "<minerals>" + "<ca>0</ca>" + "<fe>0</fe>" + "</minerals>"
+ "</food>" +
"</nutrition>";
private String verySimpleXSLT = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<xsl:stylesheet version=\"1.0\" "
+ "xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" "
+ "xmlns:fn=\"http://www.w3.org/2005/02/xpath-functions\"> " + "<xsl:output method=\"text\" />" +
"<xsl:preserve-space elements=\"*\"/>" +
"<xsl:template match=\"/\">" + "<xsl:for-each select=\"/nutrition/food\">"
+ "<xsl:value-of select=\"name\"/>" + "</xsl:for-each>" + "</xsl:template>" + "</xsl:stylesheet>";
}

View File

@@ -1,54 +0,0 @@
<h6>Test Template 1</h6>
<#-- Test basic properties -->
${root.id}<br>
${root.name}<br>
${root.properties?size}<br>
${root.children?size}<br>
<#if root.assocs["cm:translations"]?exists>
root.assocs<br>
</#if>
${root.aspects?size}<br>
<#if root.isContainer>root.isContainer</#if><br>
<#if root.isDocument>root.isDocumentr</#if><br>
<#--${root.content}<br>-->
${root.url}<br>
${root.displayPath}<br>
${root.icon16}<br>
${root.icon32}<br>
<#if root.mimetype?exists>root.mimetype</#if><br>
<#if root.size?exists>root.size</#if><br>
<#if root.isLocked>root.isLocked</#if><br>
<#-- Test child walking and property resolving -->
<table>
<#list root.children as child>
<#-- show properties of each child -->
<#assign props = child.properties?keys>
<#list props as t>
<#-- If the property exists -->
<#if child.properties[t]?exists>
<#-- If it is a date, format it accordingly-->
<#if child.properties[t]?is_date>
<tr><td>${t} = ${child.properties[t]?date}</td></tr>
<#-- If it is a boolean, format it accordingly-->
<#elseif child.properties[t]?is_boolean>
<tr><td>${t} = ${child.properties[t]?string("yes", "no")}</td></tr>
<#-- Otherwise treat it as a string -->
<#else>
<tr><td>${t} = ${child.properties[t]}</td></tr>
</#if>
</#if>
</#list>
</#list>
</table>
<#-- Test XPath -->
<#list root.childrenByXPath["//*[@sys:store-protocol='workspace']"] as child>
${child.name}
</#list>
<h6>End Test Template 1</h6>

View File

@@ -1,11 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fn="http://www.w3.org/2005/02/xpath-functions">
<xsl:output method="text" />
<xsl:preserve-space elements="*" />
<xsl:template match="/">
<xsl:for-each select="/nutrition/food">
<xsl:value-of select="name" />
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

View File

@@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fn="http://www.w3.org/2005/02/xpath-functions">
<xsl:output method="text" />
<xsl:preserve-space elements="*" />
<xsl:template match="/">
<xsl:text>G&apos;day, </xsl:text>
<xsl:for-each select="/nutrition/food">
<xsl:value-of select="name" />
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

View File

@@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fn="http://www.w3.org/2005/02/xpath-functions">
<xsl:output method="text" />
<xsl:preserve-space elements="*" />
<xsl:template match="/">
<xsl:text>Bonjour, </xsl:text>
<xsl:for-each select="/nutrition/food">
<xsl:value-of select="name" />
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>