473,785 Members | 2,188 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

[xsl] How to order this with xslt

Don't thinkt it is possible, but maybe someone knows how to do this.

I have an xml file like this:

---
<?xml version="1.0" encoding="ISO-8859-1"?>
<xc:xcontent xmlns:xc="http://www.wolterinkwe bdesign.com/xml/xcontent" xmlns="http://www.w3.org/1999/xhtml" module="agenda" >
<xc:subset offset="0" max="10" count="3"/>
<xc:agendapun t>
<xc:id>1</xc:id>
<xc:title type="string">< ![CDATA[Tjerk Jarig]]></xc:title>
<xc:date type="date">
<xc:day>02</xc:day>
<xc:month>08</xc:month>
<xc:year>2005 </xc:year>
<xc:display>200 5-08-02</xc:display>
</xc:date>
<xc:content type="html">
Ja dan ben ik jarig, blij blij blij<br/>
</xc:content>
</xc:agendapunt>

<xc:agendapun t>
<xc:id>2</xc:id>
<xc:title type="string">< ![CDATA[Radstake]]></xc:title>
<xc:date type="date">
<xc:day>18</xc:day>
<xc:month>02</xc:month>
<xc:year>2005 </xc:year>
<xc:display>200 5-02-18</xc:display>
</xc:date>
<xc:content type="html">
Avondje stake<br/>
</xc:content>
</xc:agendapunt>
<xc:agendapun t>
<xc:id>3</xc:id>

<xc:title type="string">< ![CDATA[buizen]]></xc:title>
<xc:date type="date">
<xc:day>15</xc:day>
<xc:month>02</xc:month>
<xc:year>2006 </xc:year>
<xc:display>200 6-02-15</xc:display>
</xc:date>

<xc:content type="html">
buizen
</xc:content>
</xc:agendapunt>
</xc:xcontent>
---
And a stylesheet like this (onlt this template):

---
<xsl:template match="/xc:xcontent">
<page:page type="module">
<page:form-messages multiple="agend apunt"/>
<page:button-new module="agenda" multiple="agend apunt"/>
<page:form-new multiple="agend apunt"/>
<page:form-edit multiple="agend apunt"/>
<xsl:for-each select="xc:agen dapunt">
<page:form>
<page:header><x sl:value-of select="xc:titl e"/></page:header>
<page:data>
<page:name>Datu m</page:name>
<page:value><xs l:value-of select="xc:date/xc:display"/></page:value>
</page:data>
<page:data>
<page:text-name>Content</page:text-name>
<page:text-value>
<xsl:value-of select="xc:cont ent"/>
<page:button-edit-delete module="agenda" id="{./xc:id}" multiple="agend apunt"/>
</page:text-value>
</page:data>
</page:form>
</xsl:for-each>
</page:page>
</xsl:template>
---
But what i want is the following:

I want the xc:agendapunt ordered by their <xc:data element. So that the first data is shown in the first <page:form output and the last
data is shown at the bottom.

Note that the xsl stylesheet knows some integer variables that represent the current date: $time_day $time_year $time_month.
You can use them. I do'nt know how to solve this.
Jul 20 '05 #1
2 1958
Tempore 19:40:10, die Tuesday 15 February 2005 AD, hinc in foro {comp.text.xml} scripsit Tjerk Wolterink <tj***@wolterin kwebdesign.com> :
I want the xc:agendapunt ordered by their <xc:data element. So that the first data is shown in the first <page:form output and the last
data is shown at the bottom.

Note that the xsl stylesheet knows some integer variables that represent the current date: $time_day $time_year $time_month.
You can use them. I do'nt know how to solve this.


Hi,

In Xpath 2.0, you'll have plenty of date functions to solve this properly.
But since so much data is provided, you can do it also in XSLT1.0.

Because 'xc:display' seems to be of format 'YYYY-MM-DD', you can use stringwise sort:

<xsl:for-each select="xc:agen dapunt">
<xsl:sort select="xc:date/xc:display"/>
....
</xsl:for-each>

If the 'xc:display' can't be trusted to have this structure, you can still use the order data in a numeric sort:

<xsl:for-each select="xc:agen dapunt">
<xsl:sort select="xc:date/xc:year" data-type="number"/>
<xsl:sort select="xc:date/xc:month" data-type="number"/>
<xsl:sort select="xc:date/xc:day" data-type="number"/>
....
</xsl:for-each>
regards,
--
Joris Gillis (http://www.ticalc.org/cgi-bin/acct-v...i?userid=38041)
Spread the wiki (http://www.wikipedia.org)
Jul 20 '05 #2
Joris Gillis wrote:
Tempore 19:40:10, die Tuesday 15 February 2005 AD, hinc in foro
{comp.text.xml} scripsit Tjerk Wolterink <tj***@wolterin kwebdesign.com> :
I want the xc:agendapunt ordered by their <xc:data element. So that
the first data is shown in the first <page:form output and the last
data is shown at the bottom.

Note that the xsl stylesheet knows some integer variables that
represent the current date: $time_day $time_year $time_month.
You can use them. I do'nt know how to solve this.

Hi,

In Xpath 2.0, you'll have plenty of date functions to solve this properly.
But since so much data is provided, you can do it also in XSLT1.0.

Because 'xc:display' seems to be of format 'YYYY-MM-DD', you can use
stringwise sort:

<xsl:for-each select="xc:agen dapunt">
<xsl:sort select="xc:date/xc:display"/>
...
</xsl:for-each>

If the 'xc:display' can't be trusted to have this structure, you can
still use the order data in a numeric sort:

<xsl:for-each select="xc:agen dapunt">
<xsl:sort select="xc:date/xc:year" data-type="number"/>
<xsl:sort select="xc:date/xc:month" data-type="number"/>
<xsl:sort select="xc:date/xc:day" data-type="number"/>
...
</xsl:for-each>
regards,

Thanks for your input!
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
2578
by: Simon Harvey | last post by:
Hi everyone, I am fairly new to learning about xsl and xml, but one thing I have noticed is that anyone offering a tutorial or lesson on it seems to think that its the most incredible invention ever made. I don't. I'm wondering what everyone else thinks. I know the smart answer is, use it if you need it and don't if you don't.
6
2169
by: Mark Miller | last post by:
I have a scheduled job that uses different XSL templates to transform XML and save it to disk. I am having problems with the code below. The problem shows up on both my development machine (Windows XP Pro SP 1, .Net Framework 1.1) and on our production server (Windows 2K SP 4, .Net Framework 1.1). I have simplified the code and data to isolate the problem. When I use the xsl:strip-space (Line 12) declaration in conjunction with the xsl:sort...
3
2270
by: Steve | last post by:
Is there any way of specifying the startMode when using the xslTransform class? We are updating code which used msxml to the system.xml classes but can find no way to specify the startMode. We use this so that we can specify different templates to be used by the same xml node. Know that we could use global params, but would rather not have to update all teh stylesheets and any code that uses msxml and the same stylesheets.
4
1586
by: jjouett | last post by:
I have the following input XML: <?xml version="1.0"?> <ordersubmit xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.company.com/webservices/ordersubmit"> <order> <header> <ordername>TestOrder</ordername>
6
14220
by: Jody Gelowitz | last post by:
I have run into an issue with variable scope within an XSLT document that is translated in VS.NET 2.0. Under VS.NET 1.1 (XslTransform), this code works fine. However, when using VS.NET 2.0 (XslCompiledTransform), the exact same XSLT transformation fails with the error: System.Xml.Xsl.XslLoadException: The variable or parameter 'lastrecordwaskit' was duplicated within the same scope. An error occurred at (174,12). at...
3
1882
by: howardr101 | last post by:
Hi, I'm really new to this XSL stuff and there's a lot of information out there on the web, I just can't seem to find a definitive answer to my question, hence...... In FO, I know that you define a block and use the keep-together attribute to specify whether or not the block should be split over multiple pages - unless the block itself is longer than a page.
3
5636
by: Wang Xiaoning | last post by:
i put order-by here, but i got the invalid attribut error, what's missing? thanks ----------------------------------------------------------------------------------------------------------- <?xml version="1.0" encoding="utf-8" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
6
1907
by: Christoph | last post by:
I'm trying to come up with a stylesheet where, when the rows are displayed, duplicate game names are not shown on subsequent rows. It works but doesn't work properly. If I sort the data using <xsl:sortprior to processing, it's not checking against the previous row after the sort but instead the previous row from the original data set. Here is the XML and XSL I'm using: <GameSets> <GameSetsRow> <gamename>Vampire: The Eternal...
2
1464
by: QTR | last post by:
Hello, I discovered a strange XSLT behaviour on Weblo 8.1. Let me explain it (see at the end my example XSLT): I call a template (1) with one parameter (A) which calls another template (2) with two parameters. The first parameter is param A (obtained from template 1) and the second param comes from another template (3) which just returns the given param (C). The second template receives 2 params (A and C) and prints them out. Thus, in...
1
2848
by: partheepan | last post by:
Hi, This is Parthy. Am getting this error in XSLT. Am trying to search the rows by passing parameter from C# 2.0 to XSLT. Can anyone give me a solution for this prob... The coding follows:
0
9646
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10350
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10157
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10097
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9957
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7505
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5386
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3658
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2887
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.