0

Hi All,

First time post :)

I am having a problem with sorting a for-each loop. I need to sort the data based upon a date given by a child element that has a certain attribute, confused ill show the code:

XML FILE:

<?xml version="1.0" encoding="utf-8"?>
<IssueViewXMLExport 
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40" >
<ReportMetaData>
<ReportHeader>Action Register Report for Action Register (All)</ReportHeader>
<ReportName>Action Register</ReportName>
<FilterName>(All)</FilterName>
<ProjectName>Action Register</ProjectName>
<OneIssuePerPage>false</OneIssuePerPage>
<IssueSeparatorLine>true</IssueSeparatorLine>
</ReportMetaData>
<Issues>
<Group>
<Issue>
<IVField dbColumnName="ID" FieldName="ID" FieldType="String"><![CDATA[P1146A-AC0001]]></IVField>
<IVField dbColumnName="ReportedBy" FieldName="Reported By" FieldType="Contacts"><![CDATA[test9485]]></IVField>
<IVField dbColumnName="Status" FieldName="Status" FieldType="Choice"><![CDATA[Closed]]></IVField>
<IVField dbColumnName="AssignedTo" FieldName="Assigned To" FieldType="Contacts"><![CDATA[test678]]></IVField>
<IVField dbColumnName="DueBy" FieldName="Due Date" FieldType="Date"><![CDATA[17/12/2008]]></IVField>
<IVField dbColumnName="ClosedBy" FieldName="Closed By" FieldType="Contacts"><![CDATA[test456]]></IVField>
<IVField dbColumnName="ClosedDate" FieldName="Closed Date" FieldType="Date"><![CDATA[05/01/2009]]></IVField>
<IVField dbColumnName="Abstract" FieldName="Task" FieldType="Abstract"><![CDATA[SDS to be created.]]></IVField>
<IVField dbColumnName="Description" FieldName="Description" FieldType="Text Tab"><![CDATA[]]></IVField>
<IVField dbColumnName="Notes" FieldName="Notes" FieldType="Text Tab - Secure"><![CDATA[]]></IVField>
</Issue>
<Issue>
<IVField dbColumnName="ID" FieldName="ID" FieldType="String"><![CDATA[P1146A-AC0002]]></IVField>
<IVField dbColumnName="ReportedBy" FieldName="Reported By" FieldType="Contacts"><![CDATA[test234]]></IVField>
<IVField dbColumnName="Status" FieldName="Status" FieldType="Choice"><![CDATA[Closed]]></IVField>
<IVField dbColumnName="AssignedTo" FieldName="Assigned To" FieldType="Contacts"><![CDATA[testsjsdk]]></IVField>
<IVField dbColumnName="DueBy" FieldName="Due Date" FieldType="Date"><![CDATA[12/12/2008]]></IVField>
<IVField dbColumnName="ClosedBy" FieldName="Closed By" FieldType="Contacts"><![CDATA[test]]></IVField>
<IVField dbColumnName="ClosedDate" FieldName="Closed Date" FieldType="Date"><![CDATA[05/01/2009]]></IVField>
<IVField dbColumnName="Abstract" FieldName="Task" FieldType="Abstract"><![CDATA[test]]></IVField>
<IVField dbColumnName="Description" FieldName="Description" FieldType="Text Tab"><![CDATA[]]></IVField>
<IVField dbColumnName="Notes" FieldName="Notes" FieldType="Text Tab - Secure"><![CDATA[]]></IVField>
</Issue></Issue>
</Group>
</Issues>
</IssueViewXMLExport>

The XSLT part that I am looking at:

<xsl:for-each select="Issue">
<xsl:for-each select="IVField[position() mod 3 = 1]">
<tr>
<xsl:for-each select=". | following-sibling::IVField[position() &lt; 3]">
<xsl:choose>
<xsl:when test="@FieldType = 'Text Tab' or @FieldType = 'Text Tab - Secure' or @FieldType = 'Abstract'">
<!-- No-op -->
</xsl:when>
<xsl:when test="@FieldType = 'String'">
<!-- Allow Wrap -->
<td valign="top">
<Strong>
<xsl:value-of select="@FieldName"/>
:</Strong>
</td>
<td>
<xsl:value-of select="."/>
</td>
</xsl:when>
<xsl:otherwise>
<!-- nowrap="true" -->
<td valign="top" nowrap="true">
<Strong>
<xsl:value-of select="@FieldName"/>
:</Strong>
</td>
<td valign="top" nowrap="true">
<xsl:value-of select="."/>
</td>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</tr>
</xsl:for-each> ...

I have been asked to sort the output by the "Due Date" i.e. sort the Issues for-each by the value of IVField when IVField attribute FieldName="Due Date" !

The only thing I can currently see online that will help me is http://www.biglist.com/lists/lists.mulberrytech.com/xsl-list/archives/200907/msg00065.html but I can't figure out to put this template match into my xslt.

Thanks in Advance!

David

P.S. Go easy on me I'm an XSL noob :)

Edited by David_k2: n/a

1
Contributor
1
Reply
2
Views
7 Years
Discussion Span
Last Post by David_k2
0

Hi all,

I figured out that I did not require to do this in xsl I could do it from the xml generator :).

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.