Re: Re: About XSLT/XML Pagination

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



""Nathan Nobbe"" <quickshiftin@xxxxxxxxx> wrote in message 
news:7dd2dc0b0707221103x7e8c7c8dw9439ab5fd0801c55@xxxxxxxxxxxxxxxxx
> thanks for your reply tony.
> i started reading about xsl almost 2 years ago, but only started
> experimenting using it in conjuction w/
> php about 6 months ago, so im quite new to it still.
> the greatest thing ive learned from your articles so far is a 
> modularization
> approach for the xsl files.
> my first attempt is pretty pathetic, i have just one xsl file per page, 
> and
> since the pages generally look
> the same each xsl file has a large amount of overlapping code.

Every programming language, including XSL, has the ability to take common 
code and put it in a subroutine so that it can be written just once and 
referenced many times instead of being duplicated every time. Once you know 
that in XSL these "subroutines" are called "templates" the rest is easy.

>  i knew there
> was a way to avoid this,
> but i wasnt sure how until you hopped on the list and pointed us to your
> articles and framework.
> though ive been busy with other things im looking forward to getting back
> into xsl and doing it right.
>
> ive also been building the xml data in memory, but the internal validation
> came to mind when i started
> pondering what the benefit of incorporating DTDs or XMLSchemas would be. 
> to
> illustrate what im
> imagining take some simple xml data, but imagine it has a DTD or XMLSchema
> associated with it.  now
> as part of the process of building this xml datum in memory *the system* 
> would,
> as a last step, validatate the
> datum against its DTD or XMLSchema.  the rationale here being the 
> structure
> of the memory resident
> xml may be faulty.  what im going for here is a system where developers
> would be given the responsibility
> of wrting code that would build the xml data that would in turn be handed 
> to
> the xslt processor.

If individual programmers wll have the responsibility of writing the code to 
create their own XML documents for transformation into HTML then I would 
suggest that your approach is wrong. If you look at my framework you will 
see that all XML generation is performed by a single pre-written subroutine. 
All the programmer has to do is ensure that the business object is populated 
with the correct data and everything else is automatic. There is also no 
need to write any XSL as it has already been written (and therefore tested). 
That is the benefit of a well-crafted framework.

>  i know
> we all try to do our best in life, but i imagine there would be mistakes 
> in
> the generation of said xml data
> at some point, and rather than have this impact the output of a dynamic 
> page
> wouldnt it be better for the system
> to realize an error ahead of time and handle it gracefully?

There is no point in vaidating an XML document against a DTD or XMLSchema if 
the document is going to be transformed into HTML immediately after it has 
been created as any mistakes will immediately be obvious in the HTML output. 
Either the HTML is correct, or it is not. It is as simple as that.

-- 
Tony Marston
http://www.tonymarston.net
http://www.radicore.org

> -nathan
>
> On 7/22/07, Tony Marston <tony@xxxxxxxxxxxxxxxxxxxxxxxx> wrote:
>>
>>
>> ""Nathan Nobbe"" <quickshiftin@xxxxxxxxx> wrote in message
>> news:7dd2dc0b0707220819l3ac2579aw90a8a2f9b3f1bfb1@xxxxxxxxxxxxxxxxx
>> > Tony,
>> >
>> > what are the trade offs between creating xml files and creating objects
>> in
>> > memory to
>> > pass to the xslt processor?  if arbitrary xml data is only going to be
>> > used
>> > on a single
>> > dynamic page, then is it necessary to create a file?
>>
>> Although I say XML file I actually build and process it in memory. I only
>> write a copy to disk for debugging purposes. The contents of the file (or
>> document) is the same wherever it exists.
>>
>> > also, is there any reason to leverage the validation features of xml
>> while
>> > building a dynamic page?  for instance assume data was drawn from a
>> > database to create 1 or more xml files.  would it make sense to 
>> > validate
>> > those new xml files prior to invoking the xslt processor, and 
>> > optionally
>> > not invoke the transformation process if the xml data is found to be
>> > invalid?
>>
>> This would be overkill. If you are going to build and consume an XML
>> document yourself there is no point in validating it. Remember that XML
>> was
>> originally designed as a format for data interchange, so validation is
>> only
>> necessary when you receive an XML document from a third party.
>>
>> --
>> Tony Marston
>> http://www.tonymarston.net
>> http://www.radicore.org
>>
>> > thanks,
>> >
>> > -nathan
>> >
>> > On 7/22/07, Tony Marston <tony@xxxxxxxxxxxxxxxxxxxxxxxx> wrote:
>> >>
>> >> You misunderstand that article. All pagination is done within the
>> program
>> >> code in order to construct the SQL query with the relevant LIMIT and
>> >> OFFSET
>> >> values. The entire result set is then extracted from the database and
>> >> written to an XML file, and the XSL transforms the whole XML file into
>> a
>> >> single HTML document, after which the XML document is discarded. The
>> HTML
>> >> document contains hyperlinks which allow the user to select the number
>> of
>> >> rows per page and the desired page number and these selections are
>> >> processed
>> >> within the PHP code. There is no process which goes back to the
>> previous
>> >> XML
>> >> file to extract just a subset of the rows that need to be displayed as
>> >> each
>> >> page is extracted directly from the database.
>> >>
>> >> --
>> >> Tony Marston
>> >> http://www.tonymarston.net
>> >> http://www.radicore.org
>> >>
>> >> "Kelvin Park" <kelvinpark86@xxxxxxxxx> wrote in message
>> >> news:46A3180B.3020900@xxxxxxxxxxxx
>> >> > http://www.tonymarston.net/php-mysql/xsl.html#a1
>> >> > This site generally explains how pagination is done with xslt and
>> xml.
>> >> > However it does not fully explain how to paginate the data when a
>> >> certain
>> >> > number of rows are printed.
>> >> > For example, it wouldn't make another page after 100 item names were
>> >> > printed out where total there are 1000 items that need to be printed
>> >> out,
>> >> > making it total 10 pages.
>> >> > Do you know what should be added in order to make it work?
>> >>
>> >> --
>> >> PHP General Mailing List (http://www.php.net/)
>> >> To unsubscribe, visit: http://www.php.net/unsub.php
>> >>
>> >>
>> >
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux