AnsweredAssumed Answered

List xml documents associated with template using JAVA

Question asked by parrym on Apr 21, 2009
I have this code which works from a jsp page successfully:

   public static List<PortalBean> getPortalChoices(final PageContext pageContext) throws Exception {
      final FormDataFunctions ef = new ServletContextFormDataFunctionsAdapter(pageContext.getServletContext());
      final Map<String, Document> entries = ef.parseXMLDocuments("portal", "/portals/");
      final List<PortalBean> result = new ArrayList<PortalBean>(entries.size());
      for (Map.Entry<String, Document> entry : entries.entrySet()) {
         final String fileName = entry.getKey();
         final Document d = entry.getValue();
         final Element n = (Element)d.getElementsByTagName("po:title").item(0);
         result.add(new PortalBean(n.getFirstChild().getNodeValue(),fileName));
      return result;

so far all I have this working from an alfresco xsl is this:

   public static String test() {
      return "This is a test";


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
   <xsl:output exclude-result-prefixes="fn java xsl xs"/>
   <xsl:template match="/">
      <xsl:value-of select="" />

How do I run the getPortalChoices from the xsl document as I can't seem to find a PageContext to pass to the function.


How can i rewrite the getPortalChoices function to return a list of the xml documents it finds (just the filenames is all I really need and I can then use alf:parseXMLDocument in the xsl).