Zimbra offers Open Source email server software and shared calendar for Linux and the Mac
Go Back   Zimbra :: Forums > Zimbra Collaboration Suite > Developers

Welcome to the Zimbra :: Forums!
Welcome, if you would like to post a comment please register. We also encourage you to explore all things Zimbra with our team and members of the community.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-29-2008, 03:16 PM
Junior Member
 
Posts: 7
Default SOAP and XSLT

So I get a SearchResponse back from Zimbra...

Code:
<?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
	<soap:Header>
		<context xmlns="urn:zimbra">
		...
		</context>
	</soap:Header>
	<soap:Body>
		<SearchResponse more="0" sortBy="dateDesc" offset="0" xmlns="urn:zimbraMail">
			<c f="su" id="1701" d="1201545135000" score="1.0" n="2" sf="1201545135000">
				<su>Message 1 Subject</su>
				<fr>Body Text 1.</fr>
				<e d="Jane" t="f" p="John Doe" a="user@zimbra.site.com"/>
				<m id="1731"/>
			</c>
			<c f="su" id="1702" d="1201269623000" score="1.0" n="2" sf="1201269623000">
				<su>Message 2 subject</su>
				<fr>Body Text 2.</fr>
				<e d="Jane" t="f" p="John Doe" a="user@zimbra.site.com"/>
				<m id="1728"/>
			</c>
		</SearchResponse>
	</soap:Body>
</soap:Envelope>
I am having trouble defining a .xsl document to format this SOAP response. I basically want to be able to create a list of unread messages subject/from in plain HTML via XSLT. Are their any examples or tools out there?
Reply With Quote
  #2 (permalink)  
Old 02-04-2008, 01:55 PM
Junior Member
 
Posts: 7
Default [SOLVED] SOAP and XSLT (SearchResponse)

I guess I will just answer my own question ...

This formats the XML for the query using:
HTML Code:
<types>message</types>
(whereas the xml above was derived by using the default 'c' (conversation) in that case zml:m would be zml:c).

Code:
<?xml version="1.0"?>

<xsl:stylesheet 
	version="1.0" 
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
	xmlns:env="http://www.w3.org/2003/05/soap-envelope"  
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:zml="urn:zimbraMail"> 
	
	
    <xsl:output method="html" indent="yes"/>
    
    
    <xsl:template match="/">
		<div class="sideblock">
			<div>
        	<h2>Inbox</h2><a href="#" class="toggle">+/-</a>
			</div>
		<xsl:apply-templates select="//env:Body"/>
    	</div>
    </xsl:template>
    
    
    
    
    <xsl:template match="//env:Body">
		<xsl:for-each select="//env:Body/*" >
			<xsl:apply-templates select="//env:Body/*"/>
		</xsl:for-each>    
    </xsl:template>



    <xsl:template match="zml:SearchResponse">
<div>
    	<xsl:variable name="childrenCount">
    		<xsl:value-of select="count( zml:m )" />
    	</xsl:variable>

		<xsl:if test="number($childrenCount) = 0">
			No Results
		</xsl:if>


		<xsl:if test="number($childrenCount) > 0">
	<dl>
			<xsl:for-each select="zml:m">
		
		<dt>From: <xsl:value-of select="zml:e//@p" /></dt>
		<dd>Subject: <xsl:value-of select="zml:su" /></dd>

			</xsl:for-each>
	</dl>
          </xsl:if>
</div>        
    </xsl:template>


	<xsl:template match="//env:Fault">
		 Error: <xsl:value-of select="env:Reason"/> 
	</xsl:template>

</xsl:stylesheet>
Hope this helps... I hope to add more for calendaring.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Why Join?

Registering let's you ask questions, makes it easier to search, displays any files attached to posts, and notifies you about replies.

blog.zimbra.com




 

SEO by vBSEO ©2011, Crawlability, Inc.