This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: xslt pagnation help...
- From: Joerg Heinicke <joerg dot heinicke at gmx dot de>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Sat, 10 Aug 2002 00:37:31 +0200
- Subject: Re: [xsl] xslt pagnation help...
- References: <200208091542.g79FgYn02097@allfools.net>
- Reply-to: xsl-list at lists dot mulberrytech dot com
I don't know exactly what your problem is, but I would suggest merging
the both email message types:
<?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
version='1.0' >
<xsl:output doctype-system='http://www.wapforum.org/DTD/wml_1.1.xml'/>
<!-- declare param -->
<xsl:param name="Page" select="0" />
<xsl:param name="PageSize" select="5" />
<!-- start from here -->
<xsl:template match="/">
<wml>
<card id="message">
<p>
<select name="MAILMSGCONTENT" title="MAILMSGCONTENT">
<xsl:apply-templates
select="tm_email_client/email_session_config"/>
<option onpick="#card">More</option>
</select>
<a href="#reply">Select</a>
<anchor>Back<prev/></anchor>
</p>
</card>
</wml>
</xsl:template>
<xsl:template match="email_session_config">
<xsl:for-each select="( user_email_msgs/email_msg |
default_email_msgs/email_msg ) [position() > ($Page * $PageSize)]
[position() <= $PageSize]">
<option value="{em_msg_subj}">
<xsl:value-of select="em_msg_subj"/>
</option>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Explanation for the for-each statement:
Select all user_email_msgs/email_msg and all
default_email_msgs/email_msg and create a UNION of these both node sets
(=> 1 node set). From this merged node set select all elements, whose
position() is greater than 0 (on page 0) or 5 (on page 1) and so on
(first predicate). From the rest (position() is calculated again) select
all the elements whose position() id less than or equals 5, so 5
elements are selected (or less on the last page).
Does this stylesheet what you want??
Regards,
Joerg
Zoe Peng wrote:
Hi,
I have an email service(xml document) which I'll allow user to select
pre-defined messages as email subject when user doing the reply function
(in wml that transform from xslt).
The question for me is I have too much pre-defined message that I want
to pagnation them. The pre-defined messages will includes two parts
which are user pre-defined and default.
I got problem when I have want to click [[More]] to have next page if I
devide item into 5. Please help. Thanks.
--Zoe
--xsl:
<?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
version='1.0' >
<xsl:output doctype-
system='http://www.wapforum.org/DTD/wml_1.1.xml'/>
<!-- declare param -->
<xsl:param name="Page" select="0" />
<xsl:param name="PageSize" select="5" />
<!-- start from here -->
<xsl:template match="/">
<wml>
<card id="message">
<p>
<select name="MAILMSGCONTENT" title="MAILMSGCONTENT">
<xsl:for-each
select="tm_email_client/email_session_config/user_email_msgs/email_msg">
<xsl:if test="position() >= ($Page * $PageSize) + 1">
<xsl:if test="position() <= $PageSize + ($PageSize * $Page)">
<xsl:variable name="_usr_em_msg_subj">
<xsl:value-of select="./em_msg_subj"/>
</xsl:variable>
<option value="{$_usr_em_msg_subj}">
<xsl:value-of select="$_usr_em_msg_subj" />
</option>
</xsl:if>
</xsl:if>
</xsl:for-each>
<xsl:for-each
select="tm_email_client/email_session_config/default_email_msgs/email_ms
g">
<xsl:if test="position() >= ($Page * $PageSize) + 1">
<xsl:if test="position() <= $PageSize + ($PageSize * $Page)">
<xsl:variable name="_def_em_msg_subj">
<xsl:value-of select="./em_msg_subj"/>
</xsl:variable>
<option value="{$_def_em_msg_subj}">
<xsl:value-of select="$_def_em_msg_subj" />
</option>
</xsl:if>
</xsl:if>
</xsl:for-each>
<option onpick="#card">More</option>
</select>
<a href="#reply">Select</a>
<anchor>Back<prev/></anchor>
</p>
</card>
</wml>
</xsl:template>
</xsl:stylesheet>
--xml
<?xml version="1.0"?>
<!-- <!DOCTYPE tm_email_client
SYSTEM 'http://localhost/xml/dtd/tm_email_client.dtd'>-->
<tm_email_client statuscode="0" statusdesc="Mail has been read."
action="emailreply">
<email_session_config>
<user_email_msgs usr_id="user1">
<email_msg>
<em_msg_subj>Are you testing?</em_msg_subj>
</email_msg>
<email_msg>
<em_msg_subj>How are you doing?</em_msg_subj>
</email_msg>
</user_email_msgs>
<default_email_msgs>
<email_msg>
<em_msg_subj>Yes</em_msg_subj>
</email_msg>
<email_msg>
<em_msg_subj>No</em_msg_subj>
</email_msg>
<email_msg>
<em_msg_subj>Please call</em_msg_subj>
</email_msg>
<email_msg>
<em_msg_subj>Pick Up Groceries</em_msg_subj>
</email_msg>
<email_msg>
<em_msg_subj>Call Home</em_msg_subj>
</email_msg>
<email_msg>
<em_msg_subj>Contact School</em_msg_subj>
</email_msg>
<email_msg>
<em_msg_subj>Check Post Box</em_msg_subj>
</email_msg>
<email_msg>
<em_msg_subj>Call Office</em_msg_subj>
</email_msg>
<email_msg>
<em_msg_subj>Appointment Due</em_msg_subj>
</email_msg>
<email_msg>
<em_msg_subj>Appointment Cancelled</em_msg_subj>
</email_msg>
<email_msg>
<em_msg_subj>Busy</em_msg_subj>
</email_msg>
<email_msg>
<em_msg_subj>Will Call Later</em_msg_subj>
</email_msg>
<email_msg>
<em_msg_subj>Call you back</em_msg_subj>
</email_msg>
</default_email_msgs>
</email_session_config>
</tm_email_client>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list