[Portfolio] parsing template ?

Noah Botimer botimer at umich.edu
Mon Jul 27 13:28:04 PDT 2009

Hi Jon,

You should check out XsltFunctions.java. It's not all that well  
documented, but there is a method available that turns a reference  
like that into a link, and one that extracts the item's display name.  
It might not be the same as what you'd parse out of this reference,  
but it will be the same as if it were shown in the Resources tool or  
somewhere in the UI (usually the same, though). There are also  
various other methods in there that can be called from your templates.

This technique is actually used in the default Form renderer  
(implemented in formFieldTemplate.xslt). What you're looking for is  
sakaifn:getReferenceUrl() and sakaifn:getReferenceName(), and the  
element with the attachment path is what to pass in. In this snippet,  
that's the current node, so the dot is used. The other stuff here is  
just for enough context to see the default view's attachment list in  

<!-- if there are attachments already, render these as a list -->
<!--todo: mime type lookup to resolve the icons  -->
<xsl:if test="$currentParent/node()[$name=name()]">
	<ul class="attachList labelindnt" style="clear:both;padding-top:.5em">
		<xsl:for-each select="$currentParent/node()[$name=name()]">
					<xsl:attribute name="src">
						<xsl:value-of select="sakaifn:getImageUrl(.)" />
				<input type="hidden" name="{$name}" value="{.}" />
				<a target="_blank">
					<xsl:attribute name="href">
						<xsl:value-of select="sakaifn:getReferenceUrl(.)" />
					<xsl:value-of select="sakaifn:getReferenceName(.)" />


On Jul 27, 2009, at 4:00 PM, Jon Wheat wrote:

> I have a portfolio form that collects multiple attachments.
> The resulting XML looks like this -
>      <structuredData>
>         <document>
>           <docReflection> snipped </docReflection>
>           <fileSelect>/attachment/2f0ae395-a3dd-493b- 
> b9da-141395ad34ff/Matrices/8b842f05-a344-42a0-91c3-51f138d51f62/ 
> lang_c1.pdf</fileSelect>
>           <fileSelect>/attachment/2f0ae395-a3dd-493b- 
> b9da-141395ad34ff/Matrices/426b99d2-d514-4a08-ba9a-0d00ffd8e81d/ 
> lang_c2.pdf</fileSelect>
>           <fileSelect>/attachment/2f0ae395-a3dd-493b- 
> b9da-141395ad34ff/Matrices/c0afc9de-f294-49ec-bcfc-1e47a7d7908a/ 
> lang_c3.pdf</fileSelect>
>         </document>
>       </structuredData>
> I'm now attempting to grab just the filenames for these files and  
> am having difficulty both looping though the fileSelect(s) and  
> parsing the urls so I can create simple a lang_c1.pdf link.
> Does anyone have any template code that does this ?
> - Jon
> _______________________________________________
> portfolio mailing list
> portfolio at collab.sakaiproject.org
> http://collab.sakaiproject.org/mailman/listinfo/portfolio
> TO UNSUBSCRIBE: send email to portfolio- 
> unsubscribe at collab.sakaiproject.org with a subject of "unsubscribe"

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://collab.sakaiproject.org/pipermail/portfolio/attachments/20090727/f343d05c/attachment-0001.html 

More information about the portfolio mailing list