Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display XML where vaule = value of the thing I've just clicked! 1

Status
Not open for further replies.

danfood

Programmer
Aug 8, 2001
32
0
0
GB
Hello
My problem:

Have have a search engine that returns details about a project from an XML database and displays them.
No probs.
However if the user wants to click on the "project" to find out more and display all the details I get stuck.
I'm nearly there.
Currently the user clicks on the result they want to display it calls a "generic" html page that calls the XML database and an xsl sheet.


My plan falls down at the xsl stylesheet:



<p>
<xsl:for-each select=&quot;projectdetails/project&quot;

IN HERE I WANT SOME CLEVER THING THAT SAYS ONLY SELECT &quot;PROJECTS&quot; THAT THE USER HAS JUST CLICKED ON. MY UNIQUE INDENTIFIER
IS &quot;PROJECT CODE&quot; ANY IDEAS???? I ASSUME I NEED TO STORE
A VARIABLE EQUIVALENT TO THE PROJECT CODE WHEN THE CLICK ON THE SEARCH ENGINE RESULT AND THEN REFERENCE IT HERE.>

<font face=&quot;Arial&quot; size =&quot;2&quot; color=&quot;Navy&quot;>

<p>
<b><xsl:value-of select=&quot;title&quot;/></b><br/>
<b>Project Code</b> <xsl:value-of select=&quot;projcode&quot;/><br/>
<b>Client</b> <xsl:value-of select=&quot;projclient&quot;/><br/>
<b>Project Manager</b> <xsl:value-of select=&quot;name&quot;/><br/>
</p>
<p>
<b>Project Value</b> <xsl:value-of select=&quot;projvalue&quot;/><br/>
<b>Project Status</b> <xsl:value-of select=&quot;projstatus&quot;/><br/>
</p>
<p>
<b>Project Background</b><br/>
<xsl:value-of select=&quot;Background&quot;/>
</p>
</font>
<hr />
</xsl:for-each>
</p>




</body>
</html>
</xsl:template>
</xsl:stylesheet>



 
<xsl:transform version=&quot;1.0&quot; xmlns:xsl=&quot;<xsl:param name=&quot;project&quot;>1</xsl:param>

<xsl:template match=&quot;/&quot;
<xsl:value-of select=&quot;projectdetails/project/title[projcode=$project]/>
</xsl:template>

If you accessed this stylesheet with the url it would print the title of the project with projcode of 52. if no code was given it would default to the value &quot;1&quot;.
 
Mr Tom
I don't appear to be able to get your code to work.
I am currently trying to validate it in XML Spy which I have just downloaded.

Any tips.

Dan
 
yeah, it is missing a &quot; symbol. also there's a &quot;;&quot; in the template tag too which shouldn't be there. oops.
it may not work with your code anyway, but the important thing to note is the <xsl:param> tag which sets up the value for $project. once $project is set up, it can be accessed throughout the xsl like a variable.
the value you select on your webpage is then passed to the xsl in the same way regular http forms work.
 
Hi Mr T.

I had managed to correct the typos but I haven't been able to make the code work for my purposes.
I don't really understand the <xsl:param> command.

Essentially when the user clicks on the abbreviated version of the project details I want that to link to a page that shows all the detail that we have on the project.

For example:
Results of the (javaScript) search for Mr Tom:

No 1;
Project Title: PROJECT ONE
Project Code: 12345
Project Manager: MR TOM

No 2;
Project Title: PROJECT TWO
Project Code: 98765
Project Manager: MR TOM

If you were to then click on &quot;Project 12345&quot;
it would take you to a page that displays everything about the project...

Project Title: PROJECT ONE
Project Code: 12345
Project Manager: MR TOM
Project Team: Mr Tom, Dan, Dave....
Project Timeframe: 1 Week
Other information: This is a project to etc. blah blah
......

Do I want to store the project code as a global variable?
If so how do I do this.

Is this what the Param thing is doing?
I don't quite understand how it works!

Cheers for your time.

dan
 
ok, i'm a little confused about what technologies are going where :)

when i click on project &quot;12345&quot;, is a request sent to the server for an existing page, eg &quot;12345.html&quot; or is a variable sent to a server script, eg. or is the javascript supposed to do something funky without sending any requests?

is the xsl processed server side under an ASP script or is an xml page just sent to the browser which does all the XSL itself?

i think i may have assumed you were doing it a different way and confused you more ;)
 
Whatto Mr T

Project &quot;12345&quot; is a project number that has been inputted by a user from an HTML form into an XML DB.

The story goes:

User 1
inputs details of the project with the project code 12345

this goes into an XML dbase,

<projectdetail>
various things element.... of which
<projcode>12345</projcode>
<projmanager>Mr Tom</projmanager>
</projectdetail>


User 2
searchers for &quot;MR Tom&quot;
and gets results in an HTML page:

No 1;
Project Title: PROJECT ONE
Project Code: 12345
Project Manager: MR TOM

No 2;
Project Title: PROJECT TWO
Project Code: 98765
Project Manager: MR TOM

When user 2 clicks on the hotlink Project Code 12345
the browser takes you to an new html page that displays all the details of Project One with the code 12345.

I want to create the pages of html on the fly.
Hence the xsl sheet that I gave in my original enquiry needs to be able to filter out all the projects that don't have the code 12345 and display.

At the moment I have a hotlink on each of the Project Codes (in the HTML search engine results page)
to an HTML page that calls the original XML DB with all the details in and an XSL page as shown in my orginal enquiry.
But I can't get the XSL page that does the filtering to work as I want

Sorry am I making myself clear?

XSL is doing all the work there is no ASP involved.

Regards

Dan

 
Hi Dan,

You know that you are very limited if you want to perform xsl transformations clientside??

Take a look at my post in thread426-150855

If you still want to do it clientside, Mr Tom has given you a good suggestion on how to establish this. The namespace he is refering to is not correct for client-side transformations, but he assumed (as I did when I read the thread) that you were submitting to an asp page.

The namespace you should be using for client-side transformations is:
But remember that you're making it very difficult for yourself and you are narrowing the scope of possible visitors of your page to users which use IE.

Furthermore, it's ok to ask a question, but don't expect us to write your stylesheet. If you don&#180;t know what the xsl:param does, look it up or by an xsl book. Wrox has many excellent books (
Good luck!

Jordi Reineman
 
Cheers Jordi for your comments.

I had been using the

as all the existing xsl pages had it in.
Thats when things started to go wrong.
The main book I have read (&quot;Just XSL&quot; by John E. Simpson) used the

names space (as does every other example I have since found), you are the first person to mention that the
transform namespace is for server side stuff, I thought it was just a better version of the other one. Sorry if I am really showing my inexperience now.

The more I find out the more confused I become!

This message board is my only source of help from users of these technologies when the books don't give me answers.


Dan
 
Mr Tom/JJR

JRR I'ved read your post....

Thanks for all your help, I think this namespace biz is the root of all my probs.

I have been inadvertantly trying to use functions that only work on the server-side (ie the &quot;transform&quot; namespace) with a client-side namespace....
Once I work out how to get XSL on the server, then I think I can progress.

For the moment I'm going to get the user to click on a hot link to excel and get them to update/sort a spreadsheet. there. It's bad I know but this has got way beyond my level of understanding....
 
Hi Danfood,

&quot;... to mention that the transform namespace is for server side stuff, I thought it was just a better version of the other one...&quot;

In fact it is..., but the better one isn't implemented in the parser the browser (read:IE) uses, so you're bound to the 'old' namespace or use IE 6.0. (and the transform namespace).

XSL has become a W3C recommendation last Thuesday the 16th, so from now on everybody knows what they can expect of the language and when the parsers are inplemented in the browsers the 'old' namespace will disappear completely.

Jordi Reineman
 
Jordi

If I have understood you correctly does this mean once the new parser comes out I'll be able to use the namespace in my client side transformations? (with all the wider range of functions)

Thanks

Dan
 
Hi Danfood,

Yes, once the browsers support the syntax from the recommendation (the parsers allready do) of the W3C, you can use the transform namespace in your client-side transformations.

Greetings,

Jordi Reineman
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top