Tech Support Guy banner
Status
Not open for further replies.
1 - 4 of 4 Posts

·
Registered
Joined
·
483 Posts
Discussion Starter · #1 ·
Hey!!

I am creating a site which is basically a list of books populated from a xml file called books.xml. Books have a title, author, price and genre.

I can use either Javascript or XSLT and display these perfectly.

But I want to be able to order by different values and also display say only books of the genre children or educational.

If I display it with XSLT I can do this, but it means having a different XSLT style sheet for each 'view'. Is there no way to inject data into an XSLT sheet before I load it with ajax?

For example

Code:
<xsl:sort select="price"/>
Is there any way I could use javascript to alter that from price to author? Rather than having different style sheets with just one line different. I can't find a way to pass a value to the XSLT document.

Or forgetting all that if I just use parse the XML with javascript is there anyway or ordering it using that?
 

·
Registered
Joined
·
410 Posts
How about a server side script to generate the xslt on the fly based on some vale in the query string? (hint php)

It shouldnt be too hard to do if you set the right content headers.
 

·
Registered
Joined
·
483 Posts
Discussion Starter · #3 ·
I did try this, but it seems the xsl is not recognised if it has an extension of .PHP and PHP won't run if it has an extention of .xsl. In the end I just gave up on XSLT and just used simpleXML in PHP to parse it. Seemed alot easier tbh.
 
1 - 4 of 4 Posts
Status
Not open for further replies.
Top