 |
| 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
|
|
|
|

March 28th, 2007, 09:42 AM
|
|
Registered User
|
|
Join Date: Mar 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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() > 0 and position() < 11]"> this shows from number 1 to number 10 - next is to put "NEXT 10 results"
any idea [/t]
|
|

March 29th, 2007, 03:56 PM
|
|
Friend of Wrox
|
|
Join Date: Jul 2006
Posts: 430
Thanks: 28
Thanked 5 Times in 5 Posts
|
|
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
|
|

March 31st, 2007, 05:02 AM
|
|
Registered User
|
|
Join Date: Mar 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
this will worck for me. just how, i sed im new so litle bit help will be wery good
|
|

March 31st, 2007, 06:38 AM
|
|
Friend of Wrox
|
|
Join Date: Jul 2006
Posts: 430
Thanks: 28
Thanked 5 Times in 5 Posts
|
|
I will need some of your XML and XSLT to help.
Please post and tell me what XSLT version you are using.
|
|

April 2nd, 2007, 03:48 AM
|
|
Registered User
|
|
Join Date: Mar 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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() > 0 and position() < 11]">
<div style="padding:5px; border-bottom:2px #828282 dashed;">
<div class="right"><strong>City:</strong> <xsl:value-of select="City"/><br />
<strong>Region:</strong> <xsl:value-of select="Region"/><br />
<strong>Country:</strong> <xsl:value-of select="Country"/><br />
<strong>Type:</strong> <xsl:value-of select="PropertyTypes"/><br />
<strong>From/To:</strong> <xsl:value-of select="FormattedPrice"/><br />
<strong>Quantity:</strong> <xsl:value-of select="Quantity"/><br />
<strong>Bedrooms:</strong> <xsl:value-of select="FormattedBedrooms"/><br />
<strong> Bathrooms:</strong> <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
|
|

April 2nd, 2007, 04:24 AM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
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
|
|

April 2nd, 2007, 05:04 AM
|
|
Registered User
|
|
Join Date: Mar 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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 :)
|
|

April 2nd, 2007, 06:17 AM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
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
|
|

April 2nd, 2007, 07:01 AM
|
|
Registered User
|
|
Join Date: Mar 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
10x for the help. do U tink your book is good for me, im in the begining so ...
|
|
 |