mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-07 18:25:23 +00:00
35224: ALF-12038: Remove trailing JSON comma causing IE7 script error 35226: ALF-13401 - Saving PowerPoint (mac 2011) via CIFS fails in Mac OS X Lion 35239: ALF-13409: Further fix to deal with concurrent deletion of a user's site invitations in background 35245: ALF-13281: Enabled use of autocomplete in IE for forms runtime. This change also allows multiple events to be attached per validation handler 35253: ALF-13640: Fixed issues with updating task associations + added new test + fixed existing activiti-component-tests 35271: Translation updates (fixes: ALF-13434) - based on EN r35212. (Dutch still to follow) 35281: ALF-13227: Fix CSS for Wiki layout of nested lists 35284: SPANISH: Update from Gloria 35290: More debug + unit test for mac powerpoint shuffle. 35291: Added isTemporary method 35295: ALF-13453 : Remote Code Execution (can create reverse shell). - Added ability for XMLUtil parse callers to provide an optional array of XMLFilterImpl to be used while parsing. -Added secureParseXSL methods that automatically install an XMLFilterImpl that causes a parse failure if any insecure namespaces are encountered. 35303: Fix for ALF-12444 Node Browser improvement: Index single node and remove single node from indexes Part of ALF-13723 SOLR does not include the same query unit tests as lucene 35305: ALF-13723 SOLR does not include the same query unit tests as lucene - test template 35306: ALF-13723 SOLR does not include the same query unit tests as lucene - template for creating test cores 35323: ALF-13420: Natural sort on form option labels and improvement for CSS - specifically to address transform action in document details. 35328: ALF-13409: Avoid concurrency issues in unit test tear downs by deleting users before sites. User deletion deletes invitations synchronously. Site deletion deletes invitations concurrently to avoid UI timeouts. The potential to access invitations that are being concurrently deleted still exists, but always did! 35331: ALF-12126: Ensure that DND upload is disabled for users with only consumer access 35335: ALF-13708: Merged V3.4-BUG-FIX (3.4.10) to V4.0-BUG-FIX (4.0.2) 35235: ALF-13673: Amp-loaded duplicated mimetypes should be handled - Modified code to allow duplicates to replace parts of the existing mimetype definitions. - A warning is logged each time. 35336: Spanish and Dutch updates from Gloria, based on EN r35212 35355: Merged V3.4-BUG-FIX to V4.0-BUG-FIX 35213: ALF-13686: Merged PATCHES/V3.4.8 to V3.4-BUG-FIX 34943: ALF-13121: Option to create users either as user1 or user1@domain.com after kerberos authentication - New Kerberos subsystem parameter kerberos.authentication.stripUsernameSuffix introduced - When true (the default) the @domain sufix will be stripped from Kerberos authenticated usernames in CIFS, SPP, WebDAV and the Web Client - When false, should enable a multi-domain customer to use Alfresco (says Mr Gninot) 35096: ALF-13121: Added missing stripKerberosUsernameSuffix property to sharepointAuthenticationHandler 35215: ALF-13065: Ensure Wiki new page save button is available on HTML edit action 35219: ALF-11898: Fixed TinyMCE create HTML content problem for Explorer client 35261: Translation updates based on EN r35144 35339: AD 2008 R2, user import via LDAP fails with over 1000 users - Problem discovered by Community user with simple workaround https://forums.alfresco.com/en/viewtopic.php?f=57&t=43960&sid=5569e5cfbccb3776e11ef4a8e9d50378&p=129664#p129664 35353: Merged V3.4 to V3.4-BUG-FIX 35279: ALF-13713: Merged PATCHES/V3.4.8 to V3.4 35146: Merged DEV to PATCHES/V3.4.8 35130: ALF-13472: Webdav Does not allow a user to access spaces without read permission on parent spaces Receiving of indirect lock is wrapped into AuthenticationUtil.runAs() invocation to provide a possibility of getting indirect lock for users with appropriate access rights for requested resource 35280: ALF-10353: Internet Explorer hangs when using the object picker with a larger number of documents - reviewed by DD 35318: ALF-13715: Merged HEAD to V3.4 31743: Fixed ALF-10157: Web Form Details page for the "Selected Web Content Forms": script error appears on help button click: container.jsp (line 382) 35341: ALF-13552: Merged V4.0 to V3.4 35296: ALF-13453: Remote Code Execution (can create reverse shell) - Fix by Shane 35304: ALF-13453: Extra fix to ensure xalan namespace isn't declared with global scope and can't be hijacked by an input stylesheet 35307: ALF-13453: Duplicated extra fix to duplicate code in XSLTRenderingEngine! 35354: Merged V3.4 to V3.4-BUG-FIX (RECORD ONLY) 35266: Merged V3.4-BUG-FIX to V3.4 35261: Translation updates based on EN r35144 35334: Merged V3.4-BUG-FIX to V3.4 35235: ALF-13673: Amp-loaded duplicated mimetypes should be handled - Modified code to allow duplicates to replace parts of the existing mimetype definitions. - A warning is logged each time. 35356: Merged V4.0 to V4.0-BUG-FIX 35292: ALF-13721: Merged PATCHES/V4.0.0 to V4.0 35240: Fix for ALF-13685 The SOLr textContent webscript is not protected by authentication and permission checks. 35242: Fix for ALF-13685 The SOLr textContent webscript is not protected by authentication and permission checks. - /wcs/api/solr and /wcservice/api/solr 35304: ALF-13453: Extra fix to ensure xalan namespace isn't declared with global scope and can't be hijacked by an input stylesheet 35307: ALF-13453: Duplicated extra fix to duplicate code in XSLTRenderingEngine! 35357: Merged V4.0 to V4.0-BUG-FIX (RECORD ONLY) 35048: Merged V4.0-BUG-FIX to V4.0 35031: Fix for ALF-12309: Script errors on site pages 35293: Merged V4.0-BUG-FIX to V4.0 35172: ALF-13626: category.put.json.ftl has wrong bracket 35296: Merged V4.0-BUG-FIX to V4.0 35295: ALF-13453: Remote Code Execution (can create reverse shell) - Fix by Shane git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@35359 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
381 lines
20 KiB
Java
381 lines
20 KiB
Java
/*
|
|
* 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.rendition.executer;
|
|
|
|
import java.util.Arrays;
|
|
import java.util.List;
|
|
|
|
import org.alfresco.model.ContentModel;
|
|
import org.alfresco.repo.model.filefolder.FileFolderServiceImpl;
|
|
import org.alfresco.service.cmr.model.FileFolderService;
|
|
import org.alfresco.service.cmr.model.FileInfo;
|
|
import org.alfresco.service.cmr.rendition.RenditionDefinition;
|
|
import org.alfresco.service.cmr.rendition.RenditionService;
|
|
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
|
import org.alfresco.service.cmr.repository.ContentReader;
|
|
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.TemplateException;
|
|
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.service.namespace.QName;
|
|
import org.alfresco.util.BaseAlfrescoSpringTest;
|
|
import org.alfresco.util.GUID;
|
|
import org.apache.commons.logging.Log;
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
|
|
/**
|
|
* @author Brian
|
|
*
|
|
*/
|
|
public class XSLTRenderingEngineTest extends BaseAlfrescoSpringTest
|
|
{
|
|
private final static Log log = LogFactory.getLog(XSLTRenderingEngineTest.class);
|
|
private XSLTFunctions xsltFunctions;
|
|
private SearchService searchService;
|
|
private NodeRef companyHome;
|
|
private FileFolderService fileFolderService;
|
|
private TemplateProcessor xsltProcessor;
|
|
private TemplateService templateService;
|
|
private RenditionService renditionService;
|
|
|
|
/*
|
|
* (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");
|
|
this.renditionService = (RenditionService) this.applicationContext.getBean("RenditionService");
|
|
ResultSet rs = searchService.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, SearchService.LANGUAGE_XPATH,
|
|
"/app:company_home");
|
|
this.companyHome = rs.getNodeRef(0);
|
|
}
|
|
|
|
public void testSecurityFilter() throws Exception
|
|
{
|
|
try
|
|
{
|
|
FileInfo file = createXmlFile(companyHome);
|
|
FileInfo xslFile = createXmlFile(companyHome, insecureVerySimpleXSLT);
|
|
|
|
RenditionDefinition def = renditionService.createRenditionDefinition(QName.createQName("Test"), XSLTRenderingEngine.NAME);
|
|
def.setParameterValue(XSLTRenderingEngine.PARAM_TEMPLATE_NODE, xslFile.getNodeRef());
|
|
|
|
ChildAssociationRef rendition = renditionService.render(file.getNodeRef(), def);
|
|
log.error("This insecure template should not process!");
|
|
fail();
|
|
|
|
}
|
|
catch (TemplateException e)
|
|
{
|
|
//pass!
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
log.error("Error!", ex);
|
|
fail();
|
|
}
|
|
}
|
|
|
|
public void testSimplestStringTemplate() throws Exception
|
|
{
|
|
try
|
|
{
|
|
FileInfo file = createXmlFile(companyHome);
|
|
FileInfo xslFile = createXmlFile(companyHome, verySimpleXSLT);
|
|
|
|
RenditionDefinition def = renditionService.createRenditionDefinition(QName.createQName("Test"), XSLTRenderingEngine.NAME);
|
|
def.setParameterValue(XSLTRenderingEngine.PARAM_TEMPLATE_NODE, xslFile.getNodeRef());
|
|
|
|
ChildAssociationRef rendition = renditionService.render(file.getNodeRef(), def);
|
|
|
|
assertNotNull(rendition);
|
|
|
|
ContentReader reader = contentService.getReader(rendition.getChildRef(), ContentModel.PROP_CONTENT);
|
|
assertNotNull(reader);
|
|
String output = reader.getContentString();
|
|
|
|
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 testSimplestTemplateWithTargetPath() throws Exception
|
|
{
|
|
try
|
|
{
|
|
FileInfo file = createXmlFile(companyHome);
|
|
FileInfo xslFile = createXmlFile(companyHome, verySimpleXSLT);
|
|
|
|
RenditionDefinition def = renditionService.createRenditionDefinition(QName.createQName("Test"), XSLTRenderingEngine.NAME);
|
|
def.setParameterValue(XSLTRenderingEngine.PARAM_TEMPLATE_NODE, xslFile.getNodeRef());
|
|
def.setParameterValue(RenditionService.PARAM_DESTINATION_PATH_TEMPLATE, "output/path/for/rendition/output.txt");
|
|
|
|
ChildAssociationRef rendition = renditionService.render(file.getNodeRef(), def);
|
|
|
|
assertNotNull(rendition);
|
|
assertEquals(2, nodeService.getParentAssocs(rendition.getChildRef()).size());
|
|
|
|
ContentReader reader = contentService.getReader(rendition.getChildRef(), ContentModel.PROP_CONTENT);
|
|
assertNotNull(reader);
|
|
String output = reader.getContentString();
|
|
|
|
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 testParseXMLDocument() throws Exception
|
|
{
|
|
try
|
|
{
|
|
FileInfo file = createXmlFile(companyHome);
|
|
createXmlFile(companyHome, "TestXML.xml", sampleXML);
|
|
FileInfo xslFile = createXmlFile(companyHome, callParseXmlDocument);
|
|
|
|
RenditionDefinition def = renditionService.createRenditionDefinition(QName.createQName("Test"), XSLTRenderingEngine.NAME);
|
|
def.setParameterValue(XSLTRenderingEngine.PARAM_TEMPLATE_NODE, xslFile.getNodeRef());
|
|
|
|
ChildAssociationRef rendition = renditionService.render(file.getNodeRef(), def);
|
|
|
|
assertNotNull(rendition);
|
|
|
|
ContentReader reader = contentService.getReader(rendition.getChildRef(), ContentModel.PROP_CONTENT);
|
|
assertNotNull(reader);
|
|
String output = reader.getContentString();
|
|
|
|
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 testParseXMLDocuments() throws Exception
|
|
{
|
|
try
|
|
{
|
|
FileInfo file = createXmlFile(companyHome);
|
|
String path = "path/to/xml/files";
|
|
List<String> pathElements = Arrays.asList(path.split("/"));
|
|
FileInfo folder = FileFolderServiceImpl.makeFolders(fileFolderService, companyHome, pathElements, ContentModel.TYPE_FOLDER);
|
|
createXmlFile(folder.getNodeRef());
|
|
createXmlFile(folder.getNodeRef());
|
|
createXmlFile(folder.getNodeRef());
|
|
createXmlFile(folder.getNodeRef());
|
|
createXmlFile(folder.getNodeRef());
|
|
FileInfo xslFile = createXmlFile(companyHome, callParseXmlDocuments);
|
|
|
|
RenditionDefinition def = renditionService.createRenditionDefinition(QName.createQName("Test"), XSLTRenderingEngine.NAME);
|
|
def.setParameterValue(XSLTRenderingEngine.PARAM_TEMPLATE_NODE, xslFile.getNodeRef());
|
|
|
|
ChildAssociationRef rendition = renditionService.render(file.getNodeRef(), def);
|
|
|
|
assertNotNull(rendition);
|
|
|
|
ContentReader reader = contentService.getReader(rendition.getChildRef(), ContentModel.PROP_CONTENT);
|
|
assertNotNull(reader);
|
|
String output = reader.getContentString();
|
|
|
|
log.debug("XSLT Processor output: " + output);
|
|
assertEquals(
|
|
"Avocado DipBagels, New York StyleBeef Frankfurter, Quarter PoundChicken Pot PieCole SlawEggsHazelnut SpreadPotato ChipsSoy Patties, GrilledTruffles, Dark Chocolate"+
|
|
"Avocado DipBagels, New York StyleBeef Frankfurter, Quarter PoundChicken Pot PieCole SlawEggsHazelnut SpreadPotato ChipsSoy Patties, GrilledTruffles, Dark Chocolate"+
|
|
"Avocado DipBagels, New York StyleBeef Frankfurter, Quarter PoundChicken Pot PieCole SlawEggsHazelnut SpreadPotato ChipsSoy Patties, GrilledTruffles, Dark Chocolate"+
|
|
"Avocado DipBagels, New York StyleBeef Frankfurter, Quarter PoundChicken Pot PieCole SlawEggsHazelnut SpreadPotato ChipsSoy Patties, GrilledTruffles, Dark Chocolate"+
|
|
"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() + ".xml";
|
|
return createXmlFile(folder, name, content);
|
|
}
|
|
|
|
private FileInfo createXmlFile(NodeRef folder, String filename, String content)
|
|
{
|
|
FileInfo testXmlFile = fileFolderService.create(folder, filename, 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>";
|
|
|
|
private String insecureVerySimpleXSLT = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<xsl:stylesheet version=\"1.0\" "
|
|
+ "xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" "
|
|
+ "xmlns:rt=\"http://xml.apache.org/xalan/java/java.lang.Runtime\"> "
|
|
+ "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>";
|
|
|
|
private String callParseXmlDocument = "<?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:variable name=\"cf\" select=\"alf:parseXMLDocument('TestXML.xml')\"/>" +
|
|
"<xsl:template match=\"/\">" + "<xsl:for-each select=\"$cf/food\">"
|
|
+ "<xsl:value-of select=\"name\"/>" + "</xsl:for-each>" + "</xsl:template>" + "</xsl:stylesheet>";
|
|
|
|
private String callParseXmlDocuments = "<?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:variable name=\"all_docs\" select=\"alf:parseXMLDocuments('cm:content', 'path/to/xml/files')\"/>" +
|
|
"<xsl:template match=\"/\">" + "<xsl:for-each select=\"$all_docs//food\">"
|
|
+ "<xsl:value-of select=\"name\"/>" + "</xsl:for-each>" + "</xsl:template>" + "</xsl:stylesheet>";
|
|
|
|
}
|