XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 16th, 2012, 01:46 PM
Xmonster Xmonster is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2012
Posts: 11 Xmonster User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 56 m 47 sec
Reputation Power: 0
Passing parameters

K, so this is an annoying problem, but some help would be appreciated. I'm writing an internal search engine for a site I'm working on. Basically, I have an XML file, and I have an XSL that passes parameters based on elements from that file to the search engine. The problem is, I can only get the search to work based on a single parameter.

The search form goes like this;

<form action="search_process.htm" method="get">
Enter Zip Code: <input type="text" name="ZipCode"/><br />
Sort by:
<select name="sort_by">
<option value="ages taught" onclick="useElement()">ages taught</option>
<option value="best reviewed" onclick="disableElement()">best reviewed</option>
<select><br/>
Starting From:
<select name="sort_from" id="starting_from">
<option value="5+">5+</option>
<option value="6+">6+</option>
<option value="7+">7+</option>
<option value="8+">8+</option>
</select><br/>
<input type="submit" value="submit"/>
</form>

And then the XSL extracts that zip code and displays a table of results;

<xsl:for-each select="list/instructor[zipcode=$ZipCode]">
<tr>
<td><xsl:value-of select="name"/></td>
<td><xsl:value-of select="userrating"/></td>
<td><xsl:value-of select="zipcode"/></td>
<td><xsl:value-of select="ages"/></td>
</tr>
</xsl:for-each>

The only thing in this table that affects the search, though, is the zip code. Now I need to get the three other search items listed into this code. I've tried putting it a few ways, but I can't get it right. How do I insert them?

Reply With Quote
  #2  
Old May 16th, 2012, 03:19 PM
requinix's Avatar
requinix requinix is offline
Still alive
Click here for more information.
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,717 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 4 Days 7 h 21 m 39 sec
Reputation Power: 8969
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix
You can have multiple predicates like
Code:
list/instructor[name=$Name][userrating=$UserRating][zipcode=$ZipCode][ages=$Ages]

Reply With Quote
  #3  
Old May 16th, 2012, 03:26 PM
Xmonster Xmonster is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2012
Posts: 11 Xmonster User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 56 m 47 sec
Reputation Power: 0
The table is returned with no information at all now. Do I need an xsl:sort or something? I'm really new to this.

EDIT: can predicates be conditional?

Reply With Quote
  #4  
Old May 16th, 2012, 04:54 PM
requinix's Avatar
requinix requinix is offline
Still alive
Click here for more information.
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,717 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 4 Days 7 h 21 m 39 sec
Reputation Power: 8969
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix
- The sorting is separate, but yes I think you'll want that at some point.

- As I know it no, predicates cannot be conditional. But you can put two conditions ORed together into one, like
Code:
[$Name='' or name=$Name]


- What do you have now? Hopefully the whole thing?

Reply With Quote
  #5  
Old May 17th, 2012, 11:39 AM
Xmonster Xmonster is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2012
Posts: 11 Xmonster User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 56 m 47 sec
Reputation Power: 0
I have the whole thing, yeah; there's the XML, XSL, HTML search page itself, and then a separate document with a long-*** script for removing XSL elements that don't match up with the user input.

The problem is, one search function is "Ages Taught", for the <ages> XML tag. But since the predicate dictates that ages=$sort_from, the table returns only those that match up EXACTLY with the users input, and I need it to list those that go above that value as well. If I can't write ages<=$sort_from, or even ages>=$sort_from, I'm afraid it'll get messy.

Your ORed solution sounds interesting, though; what exactly does that do?

Reply With Quote
  #6  
Old May 17th, 2012, 12:05 PM
requinix's Avatar
requinix requinix is offline
Still alive
Click here for more information.
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,717 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 4 Days 7 h 21 m 39 sec
Reputation Power: 8969
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix
An easy change would be in the form: make the age strictly numeric. No plus.
Code:
<option value="5">5+</option>


The ORed thing makes fields optional. The value is true if the field was empty or if it matches what's in the XML.

Reply With Quote
  #7  
Old May 17th, 2012, 03:05 PM
Xmonster Xmonster is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2012
Posts: 11 Xmonster User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 56 m 47 sec
Reputation Power: 0
That's not changing anything, though; the table returned still only contains one result, the result that has both search criteria EXACTLY.

The result its giving me is the one with the input zipcode and the exact age input. But there's another result I want it to list here, which lists an age higher than the input.

As for ORed; it seems to merely reinforce the variable its paired with.

Is there anything else I could be doing wrong here?

Reply With Quote
  #8  
Old May 17th, 2012, 04:11 PM
requinix's Avatar
requinix requinix is offline
Still alive
Click here for more information.
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,717 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 4 Days 7 h 21 m 39 sec
Reputation Power: 8969
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix
What's your code?

Reply With Quote
  #9  
Old May 23rd, 2012, 12:19 PM
Xmonster Xmonster is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2012
Posts: 11 Xmonster User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 56 m 47 sec
Reputation Power: 0
So it turns out your idea about removing the plus signs actually does work, but I didn't remove them from the XML. So I did that, and all is groovy now.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > Passing parameters

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap