XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
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 July 27th, 2004, 11:29 AM
1ei1a 1ei1a is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 32 1ei1a User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 28 m 13 sec
Reputation Power: 5
Question Setting an xsl:variable with a javascript value

Hi,

I am desperate for help on this.

I am currently building a Windows Sharepoint Services site. This site produces .aspx pages and incorporates webparts (made up of xml and xslts) in order to build different parts of each page.

I have a news listings xml document:
<news>
<article>
<primaryKey>1</primaryKey>
<title>news heading one</title>
<body>Body of article</body>
</article>
<article>
<primaryKey>2</primaryKey>
<title>news heading two</title>
<body>Body of article</body>
</article>
<article>
<primaryKey>3</primaryKey>
<title>news heading three</title>
<body>Body of article</body>
</article>
.
.
.
</news>

My first .aspx page, Archive.aspx, lists a summary of all my news articles sorted by primarykey. That works fine. A user should click on the "Read more" link next to an article of interest in the list, and this should then display the full article on the next page. Currently I am transferring the user to a page called Content.aspx which should handle this functionality.

Obviously at this stage I have a problem because once I am on Content.aspx, I do not know which article the user selected because I can't get my xslt to recognise the querystring containing the primarykey of the selected article. An example of my url could be: Content.aspx?PrimaryKey=2.

I want to be able to detirmine what the PrimaryKey is in the querysting and use this to select the correct article from the xml document using xslt and xpath. However, I can NOT use aspx code (the client will not allow custom code on their server) so I am stuck using Javascript.

How can I retrieve the querystring using javascript and then set an xslt:variable to be used in my stylesheet? Once it's in my stylesheet I can use xPath to locate the correct content in my xml document.

This sounds so easy it MUST be possible!!! Does anybody have any ideas at all?

Can't use the AddParameter() method as I am creating webparts. Or am I wrong???

HELP!!!!!!

Reply With Quote
  #2  
Old July 27th, 2004, 04:03 PM
Malinali Malinali is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Buenos Aires, Argentina
Posts: 74 Malinali User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
I'm not aware of how aspx works.
I usually use the XSL stylesheets by using some transformer Java servlet. The transforming servlet would have a section of the code passing all the parameters before calling the transform method. I suppose it's similar to you "addParameters()" method, and I don't know why you say you can't use it.
If the transform class would be called by something like it is in your case, I would write in my XSL something like this:

Code:
<?xml BLAH>
<xsl:param name="PrimaryKey" />
.
.
.
.
.
.
<xsl:variable name="myarticle" select="/news/article[primarykey=$PrimaryKey]"/>


And then use it and that would be it.

I think you can't use Javascript and XSL combined because Javascripts goes WHILE or AFTER the load of the finished page, and XSL is processed BEFORE it's produced.

I don't know what do you call webparts, but sometimes you can use another XML data document while processing an XSL stylesheet by using the document() method
Code:
<xsl:variable name="newData" select="document('http:(//myserver/xmldata.xml')"/>

Reply With Quote
  #3  
Old July 28th, 2004, 12:23 AM
NotGoddess's Avatar
NotGoddess NotGoddess is offline
Kung-fu Kitty
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 350 NotGoddess User rank is Sergeant (500 - 2000 Reputation Level)NotGoddess User rank is Sergeant (500 - 2000 Reputation Level)NotGoddess User rank is Sergeant (500 - 2000 Reputation Level)NotGoddess User rank is Sergeant (500 - 2000 Reputation Level)NotGoddess User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 4 Days 6 h 9 m 2 sec
Reputation Power: 10
Send a message via AIM to NotGoddess
Quote:
Originally Posted by 1ei1a
This sounds so easy it MUST be possible!!!


*rofl*
Thank you, I needed a laugh tonight.

Do you need to send the user to the Content.aspx? Could you try just opening another window with javascript and passing the content? See this url for an example: http://www.codeave.com/javascript/code.asp?u_log=7026

Reply With Quote
  #4  
Old July 28th, 2004, 02:41 AM
kid23 kid23 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 62 kid23 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
See my reply to your other post:

http://forums.devshed.com/t168864/s.html

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > Setting an xsl:variable with a javascript value


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 | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT