Jump to content

XML Searching using XSLT/Spry


Yossa70

Recommended Posts

Hi all,I'm trying to create a basic interface to be used offline. I have an XML file that I need to search by using drop down menus. Depending on the drop down menu selection, there should be a dynamic output. I'm using Dreamweaver CS which contains the Spry Datasets.I guess the easiest way to explain this is with a bit of made up XML:<?xml version="1.0" ?> - <Menu>- <Dishname>- <Steak><Meat>Yes</Meat> <Fish>No</Fish> <Pasta>No</Pasta> </Steak>- <Cod><Meat>No</Meat> <Fish>Yes</Fish> <Pasta>No</Pasta> </Cod>- <SpagBol><Meat>Yes</Meat> <Fish>No</Fish> <Pasta>Yes</Pasta> </SpagBol></Dishname></Menu>In this example, I'd have drop down menus (Meat, Fish, Pasta). If I select Meat = Yes, the dynamic part of the page should output the two dishes containing meat (Steak, Spag Bol). So far I'm OK with getting the XML into dreamweaver and putting it in drop down menus (using Spry Data Sets and Spry Repeats), but I'm not sure how to use them to filter the XML output. Is there an easier way without using Spry?Any help on this would be fantastic.Cheers....

Link to comment
Share on other sites

You should keep everything uniform in uniform elements. You are instead defining a new element for each dish. Try it with an XML like:

<?xml version="1.0" ?> <Menu><Dish name="Steak"><Meat>Yes</Meat> <Fish>No</Fish> <Pasta>No</Pasta> </Dish><Dish name="Cod"><Meat>No</Meat> <Fish>Yes</Fish> <Pasta>No</Pasta> </Dish><Dish name="SpagBol"><Meat>Yes</Meat> <Fish>No</Fish> <Pasta>Yes</Pasta> </Dish></Menu>

With this, you can use whatever language you like to get the data. I haven't worked with Spry, but I assume it's a sort of JavaScript framework? If you don't have a server side scripting language (S3L) at your disposal, you are stuck with either Spry, another JavaScript framework, or with plain JavaScript (i.e. writing a sort of JavaScript framework yourself).What is the sort of envionment you're in? What S3Ls, if any, can you use?

Link to comment
Share on other sites

Hi,Cheers for this.This will all be on an external hard drive full of video footage. The XML / front end will allow you to search for content using the drop down menus. I'm pretty new to HTML/XML/XSLT, hence all the questions...I'm not really fussed about what is used to make it work as long as it's compatible across other PC's.Cheers.

Link to comment
Share on other sites

Hi,Cheers for this.This will all be on an external hard drive full of video footage. The XML / front end will allow you to search for content using the drop down menus. I'm pretty new to HTML/XML/XSLT, hence all the questions...I'm not really fussed about what is used to make it work as long as it's compatible across other PC's.Cheers.
You mean the application needs to work directly from the eHDD? Ouch... that's the hardest type of applicaiton to write. I can see why you need to use XML.Well, you are stuck with JavaScript I suppose. That, and XSLT, which however is not that helpful for the dynamic part. Not that easily anyway.Check out Sarissa. It allows you to easily query the XML by XPath, and thus to dynamically react based on any of it's values. A value submitted by the user could easily be injected into an XPath expression, and thus the expression may dynamically query a certain thing based on the input value.
Link to comment
Share on other sites

I've had a quick look at some of the XPath stuff. It's seems fairly easy to search XML using XPath (apparently) when you can type the exact phrase in, but I've not tried to get the info from a drop down menu, into a XPath which then searches the remaining XML.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...