Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > post into xslt to change the outcome

Reply
Thread Tools

post into xslt to change the outcome

 
 
nickjtew@gmail.com
Guest
Posts: n/a
 
      10-31-2006
Hi,

I need to change the output made by my xsl file depending on what ID is
passed by the user in the browser.

The user will need to click links, eg,
http://xxx.com/blah.xml?articleid=245

The itemid will then need to be passed to the xsl, and only the article
with that id will be shown.

I've searched the web for some answers, but i cant find anything. Im
starting to believe this cant be done. Is there an alternative if it
cannot be done?

Thanks for your help
Nick

 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      10-31-2006
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:

> I need to change the output made by my xsl file depending on what ID is
> passed by the user in the browser.
>
> The user will need to click links, eg,
> http://xxx.com/blah.xml?articleid=245
>
> The itemid will then need to be passed to the xsl, and only the article
> with that id will be shown.
>
> I've searched the web for some answers, but i cant find anything.



The usual solution is server-side XSLT transformation and server-side
processing of the query string part of the URL e.g. you write an ASP (or
e.g. JSP or PHP or CGI) that takes as arguments in the query string the
URL of the stylesheet, the URL of the XML input, and any parameters to
set e.g.

<http://example.com/transform.asp?xsl=sheet1.xml&xml=file1.xml&article id=245>

then in your server side script you can execute the transformation as
needed.

The only client-side mechanism I know of is a Firefox 2.0 feature to
process special processing instructions as XSLT parameters e.g.
<http://wiki.mozilla.org/XSLT_PI_Parameters>
meaning you can pass parameters form the XML document referencing the
stylesheet. Nevertheless if you wanted to pass parameters form the URL
query string to the processor you would need server-side scripting to
read out the query string and generate those <?xslt-param?> pis.



--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
 
 
 
Dimitre Novatchev
Guest
Posts: n/a
 
      11-01-2006

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> Hi,
>
> I need to change the output made by my xsl file depending on what ID is
> passed by the user in the browser.
>
> The user will need to click links, eg,
> http://xxx.com/blah.xml?articleid=245
>
> The itemid will then need to be passed to the xsl, and only the article
> with that id will be shown.
>
> I've searched the web for some answers, but i cant find anything. Im
> starting to believe this cant be done. Is there an alternative if it
> cannot be done?


This can be done with a little bit of scripting (such as with JavaScript)
and some additional information.

Every XSLT processor has its own, implementation way of passing outside
parameters to the stylesheet. Read the vendour's documentation.

For example, for MSXML this will be done using the
IXSLProcessor.AddParameter() method.


Cheers,
Dimitre Novatchev


 
Reply With Quote
 
nickjtew@gmail.com
Guest
Posts: n/a
 
      11-02-2006
Hi,

Thanks for the reply.

I am using asp pages to show the xml with xslt (i can have more than
one xml on the page then). So a normal url will be
http://xxx.com/blah.asp?articleid=15646

The code i use on the asp page to transform the xml/xslt is

<%
xmlf = "feeds/articles.xml"
stylef = "xsl/article.xsl"
set xmlDoc = Server.CreateObject("Microsoft.XMLDOM")
set xslDoc = Server.CreateObject("Microsoft.XMLDOM")
xmlDoc.load(Server.Mappath(xmlf))
xslDoc.load(Server.Mappath(stylef))
Response.Write(xmlDoc.transformNode(xslDoc))
%>

Does this help? Could i pass the needed information in using asp?

Thanks
Nick

 
Reply With Quote
 
Dimitre Novatchev
Guest
Posts: n/a
 
      11-02-2006
Here's the example from the MSXML4 SDK -- you must have this documentation!

mk:@MSITStore:C:\Program%20Files\MSXML%204.0\doc\x mlsdk4.chm::/htm/xml_mth_ac_5pgy.htm
Dim xslt As New Msxml2.XSLTemplate40
Dim xslDoc As New Msxml2.FreeThreadedDOMDocument40
Dim xmlDoc As New Msxml2.DOMDocument40
Dim xslProc As IXSLProcessor
xslDoc.async = False
xslDoc.resolveExternals = False
xslDoc.Load "sample.xsl"
Set xslt.stylesheet = xslDoc
xmlDoc.async = False
xmlDoc.resolveExternals = False
xmlDoc.Load "books.xml"
If (xmlDoc.parseError.errorCode <> 0) Then
Dim myErr
Set myErr = xmlDoc.parseError
MsgBox("You have error " & myErr.reason)
Else
Set xslProc = xslt.createProcessor()
xslProc.input = xmlDoc
xslProc.addParameter "param1", "Hello"
xslProc.Transform
MsgBox xslProc.output
End IfFile Name: Sample.xsl

<xsl:stylesheet xmlnssl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xslutput method="html"/>
<xslaram name="param1"/>
<xsl:template match="/">
The parameter value was: <xsl:value-of select="$param1"/>
</xsl:template>
</xsl:stylesheet>


Cheers,
Dimitre Novatchev

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> Hi,
>
> Thanks for the reply.
>
> I am using asp pages to show the xml with xslt (i can have more than
> one xml on the page then). So a normal url will be
> http://xxx.com/blah.asp?articleid=15646
>
> The code i use on the asp page to transform the xml/xslt is
>
> <%
> xmlf = "feeds/articles.xml"
> stylef = "xsl/article.xsl"
> set xmlDoc = Server.CreateObject("Microsoft.XMLDOM")
> set xslDoc = Server.CreateObject("Microsoft.XMLDOM")
> xmlDoc.load(Server.Mappath(xmlf))
> xslDoc.load(Server.Mappath(stylef))
> Response.Write(xmlDoc.transformNode(xslDoc))
> %>
>
> Does this help? Could i pass the needed information in using asp?
>
> Thanks
> Nick
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Outcome of removeable drive problem pete Digital Photography 0 04-27-2007 12:26 PM
Why does adding debug statements in an override class of http-access2 change it's outcome? Dan Kohn Ruby 0 01-19-2006 12:59 AM
undefined outcome przemek drochomirecki C++ 9 06-14-2005 06:51 PM
Betting with a known outcome Moromax Computer Support 4 01-22-2004 04:50 AM
Test with weird outcome!!! Rindler Sigurd Computer Support 20 09-03-2003 11:13 AM



Advertisments