|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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!!!!!! ![]() |
|
#2
|
|||
|
|||
|
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')"/>
|
|
#3
|
||||
|
||||
|
Quote:
*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 |
|
#4
|
|||
|
|||
|
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > Setting an xsl:variable with a javascript value |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|