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 January 8th, 2010, 10:25 AM
Registered User
 
Join Date: Jan 2010
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default XML/XSLT/Xpath Image Slide Show

Hey! I am new to XSLT and Xpath.

i need to make 3 websites which display slide shows. These slide images need to change every 5 minutes.

I have been trying to create a loop in my XSLT file to identify an image through its ID number and then move to the next ID number...and this should keep going on for an many slides are there in a website...

i need 3 different loops runnings for each website...

here is my XML code...
Code:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="t2.xsl"?>
<AC2TV> 
      <website> 
          <cc> 
               
                <slide ID = "1">C:\Personal\AC2 TV\all slides\Slide1.jpg</slide> 
                <slide ID = "2">C:\Personal\AC2 TV\all slides\Slide2.jpg</slide> 
                <slide ID="3">C:\Personal\AC2 TV\all slides\Slide3.jpg"</slide> 
                
                
              </cc>
                </website> 
                <website> 
          <bc> 
               
                <slide ID = "1">C:\Personal\AC2 TV\all slides\Slide4.jpg"</slide> 
                <slide ID = "2">C:\Personal\AC2 TV\all slides\Slide5.jpg" </slide> 
                <slide ID = "3">C:\Personal\AC2 TV\all slides\Slide6.jpg" </slide> 
                
              </bc>
                </website> 
                <website> 
          <tc> 
               
               <slide ID = "1">C:\Personal\AC2 TV\all slides\Slide7.jpg" </slide> 
                <slide ID = "2">C:\Personal\AC2 TV\all slides\Slide8.jpg" </slide> 
                <slide ID = "3">C:\Personal\AC2 TV\all slides\Slide9.jpg"</slide> 
                
              </tc>
                </website> 
           
           </AC2TV>
My Xsl file so far (really coudn't do much):
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2 align="center">Control Center</h2>
<xsl:apply-templates/> 
</xsl:template>
  <xsl:for-each select="AC2TV/website/ControlCenter/Slide[@id=1]">
<xsl:if test="ID = 1">
  </body>
  </html>
Please help me...I know the discription is not very good..so plz feel free to ask questions... thanks...
 
Old January 8th, 2010, 10:34 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

A couple of points. XML is case sensitive, so <Slide> and <slide> are different elements.

Also, if you are referring to an attribute in XPATH you can use the @ shortcut, which you don't appear to be doing inside the <xsl:if> test attribute.

Then your XSLT refers to ControlCenter element, but no such element exists in your XML. Perhaps you mean "cc"?

Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
<html>
<body>
<h2 align="center">Control Center</h2>
  <xsl:for-each select="AC2TV/website/cc/slide">

    do something in here?

  </xsl:for-each>
  </body>
  </html>
</xsl:template>

</xsl:stylesheet>
Beyond that it is hard to say anything else, as you don't tell us what you actually want your output to look like.
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
 
Old January 8th, 2010, 10:44 AM
Registered User
 
Join Date: Jan 2010
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hey! thanks for the quick reply...you are correct...i did mean cc ..
m sorry about the stupid mistakes...

what I am trying to do with the XSLT code is that...

I want its to select all the ID number under cc...
once it does that...i want it to display the the image with ID = ''1" and then display the image with ID= "2" and so on...

I want to do the same for bc and tc...
 
Old January 8th, 2010, 10:55 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

you mean something like this?

[code]
<xsl:for-each select="AC2TV/website/cc/slide">
Image <xsl:value-of select="@ID"/> <img src="{text()}"/>
</xsl:for-each>
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
 
Old January 8th, 2010, 11:23 AM
Registered User
 
Join Date: Jan 2010
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hey!
I am not even being able to display one image...
can u plz help me do that...

I want to use the ID number to display images...its not working for working...
can u also suggest some website where i can take a tutorial...i have been taking tutorials online but they havn't helped much...

Code:
<xsl:for-each select="AC2TV/website/cc/slide">
<xsl:value-of select="@ID"/> 
<img id = "1">

</xsl:for-each>
 
Old January 8th, 2010, 12:38 PM
Registered User
 
Join Date: Jan 2010
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hey! So i changed the XML file a bit... and also the XSL file...

could you please check why the image is not being displayed..?

XML file
Code:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="t2.xsl"?>
<AC2TV> 
      <website> 
          <cc> 
               
                <slide>
                <img src="C:\Personal\AC2 TV\all slides\Slide1.jpg" ID="1">
                <img src="C:\Personal\AC2 TV\all slides\Slide2.jpg" ID="2">
                <img src="C:\Personal\AC2 TV\all slides\Slide3.jpg" ID="3">
                </slide> 
                
                
              </cc>
                </website> 
                <website> 
          <bc> 
               
                <slide ID = "1"><img src="C:\Personal\AC2 TV\all slides\Slide4.jpg"></img></slide> 
                <slide ID = "2"><img src="C:\Personal\AC2 TV\all slides\Slide5.jpg"></img></slide> 
                <slide ID = "3"><img src="C:\Personal\AC2 TV\all slides\Slide6.jpg"></img></slide> 
                
              </bc>
                </website> 
                <website> 
          <tc> 
               
               <slide ID = "1"><img src="C:\Personal\AC2 TV\all slides\Slide7.jpg"></img> </slide> 
                <slide ID = "2"><img src="C:\Personal\AC2 TV\all slides\Slide8.jpg"></img> </slide> 
                <slide ID = "3"><img src="C:\Personal\AC2 TV\all slides\Slide9.jpg"></img></slide> 
                
              </tc>
                </website> 
           
           </AC2TV>
XSL file

Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Edited by XMLSpy® -->

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
<html>
<body>
<h2 align="center">Control Center</h2>

<xsl:for-each select="AC2TV/website/cc">
<img>
<xsl:attribute name="id">
<xsl:value-of select="slide/img/[@id="1"]"/> 

</xsl:attribute>
</img>



</xsl:for-each>
  </body>
  </html>
</xsl:template>

</xsl:stylesheet>
 
Old January 9th, 2010, 01:29 AM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 291
Thanks: 9
Thanked 29 Times in 29 Posts
Thumbs up

Try using the below template:
Code:
<xsl:template match="/">
<html>
<body>
<h2 align="center">Control Center</h2>
<xsl:for-each select="AC2TV/website/cc/slide/img">
<xsl:copy-of select="."/>
</xsl:for-each>
</body>
</html>
</xsl:template>
If you are starting XSLT, then please start with XSLT 2.0 version.
__________________
Rummy





Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting Slide Show to work snufse ASP.NET 2.0 Basics 1 February 26th, 2009 05:47 PM
xslt slide show kawlaelo XSLT 6 February 13th, 2007 10:41 AM
Image slide-show Rajarshi HTML Code Clinic 1 February 27th, 2006 06:03 AM
Slide Show #1 (New User) WebDevel Javascript How-To 1 March 15th, 2005 09:58 AM





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