Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
| Search | Today's Posts | Mark Forums Read
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 March 28th, 2007, 09:42 AM
Registered User
 
Join Date: Mar 2007
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default xsl template, next result or next 10 results

Hi I’m new to XSLT but I manage some how to get some results from my XML data file and after that to merge them in PHP so I have now good PHP page. The thing is that the result that I get is to big I have like 40 rows of data and the page is 300kb. Just text :) . I’m trying to find a way to restrict the data whit something like “max results for page = 10“ :) but I don’t now how to do it, and to have “next 10 results” the ting is any help will be of use

I’m using <xsl:for-each select="Developments/Development> to display the data

P.S. sorry if it looks stupid question

    OK after reading the forum:
<xsl:for-each select="Developments/Development [position() &gt; 0 and position() &lt; 11]"> this shows from number 1 to number 10 - next is to put "NEXT 10 results"
any idea
[/t]
 
Old March 29th, 2007, 03:56 PM
Friend of Wrox
Points: 1,676, Level: 16
Points: 1,676, Level: 16 Points: 1,676, Level: 16 Points: 1,676, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2006
Location: , , .
Posts: 430
Thanks: 28
Thanked 5 Times in 5 Posts
Send a message via Yahoo to bonekrusher
Default

Hi,

I am not sure if you can get the output you want, however you can use parameters to get different results.

e.g.

0-10, 11-15, etc...

when these are clicked, it could pass a value to a parameter and change the output...

Just a thought

 
Old March 31st, 2007, 05:02 AM
Registered User
 
Join Date: Mar 2007
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

this will worck for me. just how, i sed im new so litle bit help will be wery good

 
Old March 31st, 2007, 06:38 AM
Friend of Wrox
Points: 1,676, Level: 16
Points: 1,676, Level: 16 Points: 1,676, Level: 16 Points: 1,676, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2006
Location: , , .
Posts: 430
Thanks: 28
Thanked 5 Times in 5 Posts
Send a message via Yahoo to bonekrusher
Default

I will need some of your XML and XSLT to help.

Please post and tell me what XSLT version you are using.

 
Old April 2nd, 2007, 03:48 AM
Registered User
 
Join Date: Mar 2007
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

this is the XSLT im using Macromedia to make it, the ting is that they have wery nice tutorial how to make XSLT page from existing XML :)
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE xsl:stylesheet [
    <!ENTITY nbsp "#160;">
    <!ENTITY copy "#169;">
    <!ENTITY reg "#174;">
    <!ENTITY trade "#8482;">
    <!ENTITY mdash "#8212;">
    <!ENTITY ldquo "#8220;">
    <!ENTITY rdquo "#8221;">
    <!ENTITY pound "#163;">
    <!ENTITY yen "#165;">
    <!ENTITY euro "#8364;">
]>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="iso-8859-1" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
<xsl:template match="/">
<xsl:comment>
</xsl:comment>
    <xsl:for-each select="Developments/Development[Country='Spain'][position() &gt; 0 and position() &lt; 11]">
      <div style="padding:5px; border-bottom:2px #828282 dashed;">
        <div class="right"><strong>City:</strong> &nbsp;<xsl:value-of select="City"/><br />
          <strong>Region:</strong> &nbsp; <xsl:value-of select="Region"/><br />
          <strong>Country:</strong> &nbsp; <xsl:value-of select="Country"/><br />
          <strong>Type:</strong> &nbsp;<xsl:value-of select="PropertyTypes"/><br />
          <strong>From/To:</strong> &nbsp;<xsl:value-of select="FormattedPrice"/><br />
            <strong>Quantity:</strong> &nbsp; <xsl:value-of select="Quantity"/><br />
            <strong>Bedrooms:</strong> &nbsp; <xsl:value-of select="FormattedBedrooms"/><br />
        <strong> Bathrooms:</strong> &nbsp; <xsl:value-of select="FormattedBathrooms"/><br />
        <a href="javascript:void(0)" style="display:block; border:2px #FFFFFF solid; padding:2px; text-align:center; background-color: #D5D5D5" onclick="window.open('contact-developments.php?comments=Please send me more information for {Name} Development in {Country}','Contact','width=360,height=240')"><str ong>Send enquiry for this Development</strong></a> </div>
        <h2><xsl:value-of select="Name"/></h2>
        <h3 align="justify" class="Table-border"><xsl:value-of select="SummaryText"/></h3>
        <p align="justify"><img src="{LargeImage1}" alt="{Name}" hspace="1" vspace="1" border="1" style="float:left; margin-right:3px"/><xsl:value-of select="DevelopmentText"/> <xsl:value-of select="PropertiesText"/> <xsl:value-of select="AreaText"/></p>
        <p class="Table-border"><a href="{LargeImage2}" target="_blank" ><img src="{SmallImage2}" alt="{Name}" width="115" height="78" hspace="1" border="0" class="bgOrange"/></a> <a href="{LargeImage3}" target="_blank"><img src="{SmallImage3}" alt="{Name}" width="115" height="78" hspace="1" border="0" class="bgOrange" /></a> <a href="{LargeImage4}" target="_blank"><img src="{SmallImage4}" alt="{Name}" width="115" height="78" hspace="1" border="0" class="bgOrange" /></a> <a href="{LargeImage5}" target="_blank"><img src="{SmallImage5}" width="115" height="78" hspace="1" border="0" class="bgOrange" alt="{Name}" /></a> <a href="{LargeImage6}" target="_blank"><img src="{SmallImage6}" width="115" height="78" hspace="1" border="0" class="bgOrange" alt="{Name}" /></a> <a href="{LargeImage1}" target="_blank"><img src="{SmallImage1}" width="115" height="78" hspace="1" border="0" class="bgOrange" alt="{Name}"/></a><br />
        </p> </div>
        </xsl:for-each>
 </xsl:template>
</xsl:stylesheet>

and this is the XML, i have replase some of the text the root/if i have to sey like that is <Developments> and every development start whit <Development> and end whit </Development>
<Developments>
    <Development>
        <DevelopmentID>3</DevelopmentID>
        <Name>sghss sdfh sdfhs</Name>
        <SummaryText>xhshsh sdfghsd fhsdfh s</SummaryText>
        <DevelopmentText>fgsgsa srgs hsd hsdhs </DevelopmentText>
        <PropertiesText>arga a sag asdgrsrg asgasdf</PropertiesText>
        <AreaText>sjdgskdfjgsdjklfgsjdhgskdjghskdjghksjg hs sglsdjkg sl</AreaText>
        <City>Vea</City>
        <Region>Costa</Region>
        <Country>Spain</Country>
        <CountryCode>ES</CountryCode>
        <PropertyTypes>Apartment</PropertyTypes>
        <Quantity>250</Quantity>
        <MinBedrooms>2</MinBedrooms>
        <MaxBedrooms>3</MaxBedrooms>
        <FormattedBedrooms>2 - 3</FormattedBedrooms>
        <MinBathrooms>2</MinBathrooms>
        <MaxBathrooms>2</MaxBathrooms>
        <FormattedBathrooms>2</FormattedBathrooms>
        <MinPrice>170500.00</MinPrice>
        <MaxPrice>210000.00</MaxPrice>
        <CurrencyCode>EUR</CurrencyCode>
        <FormattedPrice>#8364;170,500 - #8364;210,000</FormattedPrice>
        <ImageCount>6</ImageCount>
        <LargeImage1>http*</LargeImage1>
        <LargeImage2>http*</LargeImage2>
        <LargeImage3>http*</LargeImage3>
        <LargeImage4>http*</LargeImage4>
        <LargeImage5>http*</LargeImage5>
        <LargeImage6>http*</LargeImage6>
        <SmallImage1>http*</SmallImage1>
        <SmallImage2>http*</SmallImage2>
        <SmallImage3>http*</SmallImage3>
        <SmallImage4>http*</SmallImage4>
        <SmallImage5>http*</SmallImage5>
        <SmallImage6>http*</SmallImage6>
    </Development>
</Developments>

so this is 10x for your help in advance :)
P.S. - sorry for my bad english

 
Old April 2nd, 2007, 04:24 AM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

This code looks fine except that the predicate [position() > 0 and position() < 11] needs to be changed to something like [position() >= $start and position() <= $start + $size}, where $start and $size are declared as global stylesheet parameters using xsl:param, and the actual values of the parameters are supplied at run-time by the calling application. The exact way that you supply parameter values depends on the XSLT processor API that you are using.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old April 2nd, 2007, 05:04 AM
Registered User
 
Join Date: Mar 2007
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

it is starts to get more complicated and more. How i can chek the processor API that im using. i have to chek alsou for the sintaxys of xsl:param. im starting to like this forum :)

 
Old April 2nd, 2007, 06:17 AM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Don't try to use the forum as a substitute for a good text book!

For details of your processor API you first need to know which XSLT processor you are using.

xsl:param you can find documented in any XSLT reference book.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old April 2nd, 2007, 07:01 AM
Registered User
 
Join Date: Mar 2007
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

10x for the help. do U tink your book is good for me, im in the begining so ...




Similar Threads
Thread Thread Starter Forum Replies Last Post
xsl:exclude-result-prefixes #all and #default maxtoroq BOOK: XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition ISBN: 978-0-470-19274-0 4 July 28th, 2008 12:10 PM
CSS Instant Results: Project 6 & 10 ericcutty BOOK: CSS Instant Results 1 October 11th, 2007 08:45 AM
xsl:result-document instruction bonekrusher XSLT 3 April 12th, 2007 06:01 PM
Using result of one template in another rhajikhani XSLT 1 June 4th, 2006 04:56 PM
how to use call-template result in a test? briforge XSLT 6 February 13th, 2006 06:54 PM





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