Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 20th, 2007, 09:18 AM
Registered User
 
Join Date: Oct 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Newbie help...

I am trying to customize and existing discussion board that is created with xslt and javascript. The data returns title, ordering and modified. A function is used to validate if an item is new and render an image next to the post. Discussion threading is done by javascript as the ordering field are appended to determine whether or not a post is a reply to an existing thread or a new thread entirely.

title ordering modifiedDate


I want to be able to show that new icon at the parent thread where the ordering value starts. Is there a way to look at all of the ordering fields (or at least until the first 9 characters change) and then come back to the first one to render my image?

201070908 (top thread) ....I want to show icon here
201070908234255 (reply)
201070908245674 (reply)
201070908234665345456345 (reply to reply) Modified is Today NEW Post!
201070910 (new thread)
201071010 (new thread)

Thanks for any help!



 
Old October 20th, 2007, 11:27 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

It's easier to answer questions like this if you can show your XML input and your HTML output, simplified if necessary to make them easier to understand.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old October 21st, 2007, 11:54 PM
Registered User
 
Join Date: Oct 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I want to replicate the following as a cell in another xslt below

<xsl:for-each select="//Row[not(./@ThreadID = preceding::Row/@ThreadID)]">
                    <xsl:variable name="curThreadID" select="@ThreadID"/>

                    <xsl:variable name="postNodes" select="//Row[@ThreadID = $curThreadID]"/>
                    <xsl:variable name="postCount" select="count($postNodes)"/>
                    <xsl:variable name="firstPost" select="$postNodes[$postCount]"/>
                    <xsl:variable name="lastPost" select="$postNodes[1]"/>
                    <TR name="row" style="display:auto">

                        <TD Class="ms-vb2" nowrap="true">
                            <xsl:value-of select="ddwrt:FormatDateTime(string($lastPost/@Created) ,1033 ,string($PostDateTimeFormat))"/>
                          by
                          <xsl:call-template name="RenderNameWithIMNRC"><xsl:with-param name="Author" select="$lastPost/@Author"/><xsl:with-param name="ItemID" select="$lastPost/@ID"/></xsl:call-template></TD>
                    </TR>
                </xsl:for-each>


Here's the separate snip from a working XSLT that I want to include another cell in. Please excuse the missing closed tags but I am interested in how I can include this is the sort order is different...

        <xsl:template name="dvt_1.body">
            <xsl:param name="Rows"/>
            <xsl:param name="FirstRow"/>
            <xsl:param name="LastRow"/>
            <xsl:variable name="AdHocGroupDir"><xsl:choose xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:when test="$dvt_groupdir='desc'">descending</xsl:when><xsl:otherwise>ascending</xsl:otherwise></xsl:choose></xsl:variable>
            <xsl:variable name="AdHocSortDir"><xsl:choose xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:when test="$dvt_sortdir='desc'">descending</xsl:when><xsl:otherwise>ascending</xsl:otherwise></xsl:choose></xsl:variable>
            <xsl:for-each select="$Rows">
                <xsl:variable name="KeepItemsTogether" select="false()"/>
                <xsl:variable name="HideGroupDetail" select="false()"/>
                <xsl:variable name="GroupStyle" select="'auto'"/>
                <xsl:if test=" (position() &gt;=$FirstRow and position() &lt;= $LastRow) or $KeepItemsTogether">
                    <xsl:if test="not($HideGroupDetail)" ddwrt:cf_ignore="1">
                        <TR name="row" style="display:{$GroupStyle}">
                                    <TD Class="{$IDAABQ0C}">
                                        <table border="0" cellpadding="0" cellspacing="0" width="100%" MsoPnlId="data">
                                            <tr>
                                                <td class="ms-vb" name="indent" width="0"/>
                                                <td class="ms-vb"><table PostID="{@GUID}" border="0" cellpadding="0" cellspacing="0" width="100%" MsoPnlId="data"><tr><td class="ms-vb" style="padding-top: 1px;"><a name="post" style="cursor: default" tabindex="2"><img name="widget" id="{@Ordering}" border="0" src="/_layouts/images/discbul.gif"/></a><xsl:text xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" ddwrt:nbsp-preserve="yes" disable-output-escaping="yes">&amp;nbsp;</xsl:text></td><td class="ms-vb" width="100%"><xsl:choose><xsl:when test="ddwrt:GetVar('SelectedID')=@ID"><b><xsl:valu e-of disable-output-escaping="no" select="@Title"/></b><xsl:if test="ddwrt:IfNew(string(@Created))"><IMG SRC="/_layouts/1033/images/new.gif" alt="New"/></xsl:if></xsl:when><xsl:otherwise><table height="100%" cellspacing="0" class="ms-unselectedtitle" onmouseover="OnItem(this)" CTXName="ctx99" ItemId="{format-number(string(@ID), '#;-#')}" Ordering="{@Ordering}" ThreadID="{@ThreadID}" Subject="{@Title}" MsoPnlId="data"><tr><td width="100%" Class="ms-vb"><a onfocus="OnLink(this)" href="{$URL_Display}?ID={@ID}" ONCLICK="GoToPage('{$URL_Display}?ID={@ID}');retur n false;" target="_self"><xsl:value-of disable-output-escaping="no" select="@Title"/></a><xsl:if test="ddwrt:IfNew(string(@Created))"><IMG SRC="/_layouts/1033/images/new.gif" alt="New"/></xsl:if></td><td><img src="/_layouts/images/blank.gif" width="13" style="visibility: hidden" alt=""/></td></tr></table></xsl:otherwise></xsl:choose></td></tr></table><table name="body" STYLE="display:" width="100%" MsoPnlId="data"><tr><td class="ms-vb" width="5"><xsl:text xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" ddwrt:nbsp-preserve="yes" disable-output-escaping="yes">&amp;nbsp;</xsl:text></td><td class="ms-vb"><xsl:choose><xsl:when test="@Body=''">(no text)</xsl:when><xsl:otherwise><xsl:choose><xsl:when test="''='TRUE'"><div><xsl:value-of disable-output-escaping="no" select="ddwrt:Limit(string(@Body), 400, '...')"/></div></xsl:when><xsl:otherwise><xsl:value-of disable-output-escaping="no" select="ddwrt:Limit(string(@Body), 400, '...')"/></xsl:otherwise></xsl:choose></xsl:otherwise></xsl:choose></td></tr></table></td>
                                            </tr>
                                        </table>
                                    </TD>



 
Old October 22nd, 2007, 03:00 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

I am sorry, but I've no idea what your problem is, I don't know what the source document looks like, I don't know what you want the result to be, and the fragment of code you have shown is totally unreadable.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old October 23rd, 2007, 02:31 PM
Registered User
 
Join Date: Oct 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Michael,

I appreciate the reply but there's 120+ lines in one stylesheet and there's even more with the original (680 lines) along with scripting that is rendering the interface so I think I am at a loss for even what to post as a sample.

-Mark

 
Old October 23rd, 2007, 04:26 PM
Registered User
 
Join Date: Oct 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hopefully this makes sense. I dont have a sample XML file to display so I only have the XSLT. I am building a table of rows based on the XML data. Is it possible to interrupt the "for-each" loop in the template with another "for-each" loop? One of the cells in my table's row can only be obtained by reversing the sort order of the date because it's essentially a count and then a display of the date of the most recent item in the node. I basically displaying the parent node and I want the date of the most recent item in the node.

In my template, I have the following:

<xsl:for-each select="//Row[not(./@ThreadID = preceding::Row/@ThreadID)]">
<xsl:variable name="curThreadID" select="@ThreadID"/>
<xsl:variable name="postNodes" select="//Row[@ThreadID = $curThreadID]"/>
<xsl:variable name="postCount" select="count($postNodes)"/>
<xsl:variable name="firstPost" select="$postNodes[$postCount]"/>
<xsl:variable name="lastPost" select="$postNodes[1]"/>

That enables me to manipulate the variables the way I want.

My other XSLT starts this way:
<xsl:for-each select="$Rows">
<xsl:variable name="KeepItemsTogether" select="false()"/>
<xsl:variable name="HideGroupDetail" select="false()"/>
<xsl:variable name="GroupStyle" select="'auto'"/>
<xsl:if test=" (position() &gt;=$FirstRow and position() &lt;= $LastRow) or $KeepItemsTogether">
<xsl:if test="not($HideGroupDetail)" ddwrt:cf_ignore="1">
<TR name="row" style="display:{$GroupStyle}">


I want to add a cell just after this that iterates through the data listed above.

Make sense? I hope.... :(

Mark

 
Old October 23rd, 2007, 04:42 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

I'm sorry, I've spent several minutes staring at this, but without knowing what your input and output look like, it's impossible to help. I've said it three times now, so it must be true.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old October 24th, 2007, 02:33 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

If you show a sample of the XML containing the posts it would be easier. When you create the output for the first message in the thread you can check if any of the associated messages are new. All that is needed is to know how the thread is marked if new.

--

Joe (Microsoft MVP - XML)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Please help the newbie!! shelly.aix Visual Basic 2008 Essentials 2 December 16th, 2008 07:35 AM
Newbie here jmac731976 HTML Code Clinic 13 August 29th, 2007 03:54 PM
Newbie please help indyanguy XSLT 1 September 2nd, 2005 09:18 AM
Newbie Help! TheShadow Javascript 1 March 21st, 2005 03:42 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.