XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 22nd, 2004, 03:55 AM
echo echo is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2001
Posts: 16 echo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 m 56 sec
Reputation Power: 0
XSL/XSLT one random node display, need help

Hello,

I am trying to accomplish to get from XML via XSL display of one random node, in my case "item" node.

I have tried with below code, but won't work.

I need it from XSL or XSLT ... thx in advance for help.



Code:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
	<xsl:output method="html" version="4.0" encoding="iso-8859-1" indent="yes"/>
	<xsl:template match="/">
		<xsl:apply-templates/>
	</xsl:template>
	<xsl:template match="channel">
		<xsl:apply-templates select="item[position()<=1]"/>
		<xsl:apply-templates select="math:random(count(item))"/>
		<xsl:copy-of select="item[position() = current()]"/>
	</xsl:template>
	<xsl:template match="image">
		<a target="_blank">
			<xsl:attribute name="href">
				<xsl:value-of select="link"/>
			</xsl:attribute>
			<img>
				<xsl:attribute name="src">
					<xsl:value-of select="url"/>
				</xsl:attribute>
				<xsl:attribute name="alt">
					<xsl:value-of select="title"/>
				</xsl:attribute>
				<xsl:attribute name="width">
					<xsl:value-of select="width"/>
				</xsl:attribute>
				<xsl:attribute name="height">
					<xsl:value-of select="height"/>
				</xsl:attribute>
			</img>
		</a>
	</xsl:template>
	<xsl:template match="item">
		<strong>
			<a target="_blank">
				<xsl:attribute name="href">
					<xsl:value-of select="link"/>
				</xsl:attribute>
				<xsl:value-of select="title" />
			</a>
		</strong>
		<xsl:apply-templates select="description"/>
	</xsl:template>
	<xsl:template match="description">
		<br>
			<xsl:value-of select="." disable-output-escaping="yes"/>
		</br>
		<br></br>
		<br></br>
	</xsl:template>
	<xsl:template match="text()"/>
</xsl:stylesheet>

Reply With Quote
  #2  
Old July 27th, 2004, 04:34 PM
Malinali Malinali is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Buenos Aires, Argentina
Posts: 74 Malinali User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Could you please copy a piece of you XML so we can see the layout?

Reply With Quote
  #3  
Old August 4th, 2004, 09:03 AM
echo echo is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2001
Posts: 16 echo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 m 56 sec
Reputation Power: 0
url to amazon xml

I wish to display one random book with small book cover "ImageUrlSmall" node and "Detalils url=" for clicking on book for destination link to amazon.

thx in advance

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > XSL/XSLT one random node display, need help


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT