Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

server variables in XSL

Posted on 2000-05-04
3
Medium Priority
?
502 Views
Last Modified: 2006-11-17
is there any way to access global or server variables in XSL scripting
0
Comment
Question by:tommyh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 44

Expert Comment

by:bruintje
ID: 2777996
Hi tommyh,

A sample of how to do it can be found here

http://zvon.vscht.cz/HTMLonly/XSLTutorial/Examples/Example34/exampleInOne.html

On this page the author gives one way how to do it right and a second of how not to do it...

Coming from an excellent overall tutorial here

http://zvon.vscht.cz/HTMLonly/XSLTutorial/Books/Book1/bookInOne.html#chapter9

HTH:O)Bruintje
0
 

Author Comment

by:tommyh
ID: 2778714
is this relevant to asp and msxml parser?, and what about server variables?
0
 

Accepted Solution

by:
youngpup earned 100 total points
ID: 2861710
You can do this a couple different ways, tommy....

(these all relate specifically to ASP ans msXML, cuz that's what I have experience in)

1) if you have access to IIS, go into the control panel for the server you're working on and register .xml files to be parsed by ASP. This is in "Application properties" or something like that... by default ASP parses only .asp and .inc files. but you can add as many as you like. Then, in you're xml file, you can stick ASP, and everything'll be fine as long as what's returned is valid XML/XSL...

<xsl:template match="//<%=Request.ServerVariables("whatever")%>">


2) if no access to IIS, or its impractical - you can rename your .xml files .asp. Then use the same technique as above. The downside is that these .xml files will no longer work for direct download to an XML-capable client such as IE5 - because it won't see the .xml extension, and therefore won't know to switch to xml mode.


3) the final solution is messy, but sometimes necessary. Instantiate the XMLDom object in ASP, add nodes to the source XML document that represent the global variables you want to get in to XSL, and assign them values. Then your XSL just looks for these added nodes.

Set oXMLDoc = Server.CreateObject("Microsoft.XMLDOM")
Set oXSLDoc = Server.CreateObject("Microsoft.XMLDOM")

oXSLDoc.async = false
oXMLDoc.async = false

oXMLDoc.load(server.mappath(sFullPathToXml))
oXSLDoc.load(server.mappath(sPathToXsl))
set c = oXMLDoc.documentElement
set a = oXMLDoc.createElement("myvar")
set b = oXMLDoc.createTextNode(myvalue)
a.appendChild(b)
c.appendChild(a)

response.write oXMLDoc.transformNode(oXSLDoc)

...........


<xsl:apply-templates....>
  <xsl:value-of select="//myvar"/>
</xsl:apply-templates>




....

get it??
:)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question