473,386 Members | 1,841 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

post into xslt to change the outcome

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

Oct 31 '06 #1
4 1495
ni******@gmail.com 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/
Oct 31 '06 #2

<ni******@gmail.comwrote in message
news:11**********************@e64g2000cwd.googlegr 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
Nov 1 '06 #3
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

Nov 2 '06 #4
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 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="html"/>
<xsl:param name="param1"/>
<xsl:template match="/">
The parameter value was: <xsl:value-of select="$param1"/>
</xsl:template>
</xsl:stylesheet>
Cheers,
Dimitre Novatchev

<ni******@gmail.comwrote in message
news:11**********************@h48g2000cwc.googlegr 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

Nov 2 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Alexis | last post by:
Hi, I need to transform one xml document into a second xml document. They both have many nodes so xslt works fine, but there is one node I have not figure out how to transform. Here it is:...
7
by: mike p. | last post by:
I have a docbook xml file, and am using standard docbook 1.61.3 xsl stylesheets to do xhtml transform. Transform works fine when using MSXML. When I try to do the following using asp.net 1.1: ...
2
by: sam | last post by:
Hi, I've been buried in xsl and xslt articles for several days now, and am still unsure as to what I need to do... Basically, my vb.net app loads up an XML file from an external source...
7
by: Harolds | last post by:
The code below worked in VS 2003 & dotnet framework 1.1 but now in VS 2005 the pmID is evaluated to "" instead of what the value is set to: .... xmlItems.Document = pmXML // Add the pmID...
3
by: super.raddish | last post by:
Greetings, I am relatively new to, what I would call, advanced XSLT/XPath and I am after some advice from those in the know. I am attempting to figure out a mechanism within XSLT to compare the...
8
by: ak | last post by:
Hi Guys, I was just wondering whether it is possible to translate JSP pages into ASP pages using XSLT. What I want is to be able to open a currently available website developed in JSP in a...
3
by: =?iso-8859-1?q?Christian_R=FChl?= | last post by:
Hi folks! I have a little noob problem here with XSLT. I have a XML file that looks like this: <archiveFiles> <module path="c:/temp/module_m17_blabla.tmp"/> <module...
1
by: Nougatti | last post by:
Hi, I am trying to remove part of an xml file using xslt. The output should be an exact copy of the input, but one node should be removed based on an attribute value. for instance: <AAA> ...
2
jkmyoung
by: jkmyoung | last post by:
Here's a short list of useful xslt general tricks that aren't taught at w3schools. Attribute Value Template Official W3C explanation and example This is when you want to put dynamic values...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.