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 November 5th, 2003, 12:25 PM
Registered User
 
Join Date: Nov 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default DataIsland + Sort + link on JavaScript

Hi all,
I need to do the following
I have an XML file with a XSL, I would like to create a DataIsland and put this data into a table, sort this table , and show 2 records on each page.
To do this I have the following
---BEGIN XML FILE
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="ISLA_XSL.xsl"?>
<LIBROS>
    <LIBRO>
        <ID>1</ID>
        <TITULO>Libro2</TITULO>
    </LIBRO>
    <LIBRO>
        <ID>4</ID>
        <TITULO>Libro3</TITULO>
    </LIBRO>
    <LIBRO>
        <ID>2</ID>
        <TITULO>Libro4</TITULO>
    </LIBRO>
    <LIBRO>
        <ID>3</ID>
        <TITULO>Libro1</TITULO>
    </LIBRO>
</LIBROS>
---END XML FILE
--BEGIN XSL FILE
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<HTML>
<HEAD>
<TITLE></TITLE>
<SCRIPT LANGUAGE="vbscript">
Sub anterior_onclick
    Tabla.PreviousPage
End Sub
Sub siguiente_onclick
    Tabla.NextPage
End Sub
</SCRIPT>
</HEAD>
<BODY>
<Table DataSRC="#datos" datapagesize="2" border="1" id="Tabla">
<thead>
<tr>
    <TH>Titulo</TH>
</tr>
</thead>
<TBody>
<tr>
    <td><input type="text" DataFLD="TITULO"></input></td>
    <td><a href="test.asp"><span DATAFLD="ID"></span></a></td>
</tr>
</TBody>
</Table>
<INPUT id="Anterior" style="LEFT: 173px; TOP: 39px" type="button" value="Anterior"></INPUT>
<INPUT id="siguiente" style="LEFT: 173px; TOP: 39px" type="button" value="Siguiente"></INPUT>
<XML ID="Datos">
<LIBROS>
    <xsl:apply-templates select="//LIBRO">
          <xsl:sort select="TITULO"></xsl:sort>
    </xsl:apply-templates>
</LIBROS>
</XML>
</BODY>
</HTML>
</xsl:template>

<xsl:template match="LIBRO">
<LIBRO>
    <ID><xsl:value-of select="ID"></xsl:value-of></ID>
    <TITULO><xsl:value-of select="TITULO"></xsl:value-of></TITULO>
</LIBRO>
</xsl:template>
</xsl:stylesheet>
--END XSL FILE

With this I can create a table sort the XML file by TITULO, and create a pagination inside table. This is running ok, but I need that the link on Id would be on this way :
<a href="test.asp?id=*>ID</a>, where * is the ID on XML file, i can´t put this because into a table with DATASRC I only can show xml file into the span, div or input tags with the parameter DATAFLD="XML_ELEMENT"

Anybody know if is posible to do this?

Thanks to all.
PD: Sorry for my english.



 
Old November 5th, 2003, 02:11 PM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

You need some script in the a element to read the id:
Code:
<a href="test.asp" onclick="call followLink(Me)"><span datafld="ID"></span><a>
then a function:
Code:
Function followLink(Link)
  Dim sId, sUrl
  sId = Link.children[0].innerText
  sUrl = Link.href & "?id" & sId 
  alert(sUrl) 'Testing...
  window.location.href = sUrl 
  window.returnValue = False
  followLink = False
End Function
Joe (MVP - xml)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Create properties for javascript link ismailc XSLT 3 December 10th, 2007 09:41 AM
how to sort cross tab.sort based on row total joxa83 Crystal Reports 7 March 2nd, 2006 09:12 AM
Unable to sort using xsl sort command sly_jimmy_boy XSLT 3 June 17th, 2005 05:15 AM
XML dataisland / sql XueXue XML 2 November 11th, 2004 02:25 PM
Table Sort With Javascript Ben Horne Javascript How-To 5 November 6th, 2003 05:50 AM





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