?
Solved

server variables in XSL

Posted on 2000-05-04
3
Medium Priority
?
500 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
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, …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month13 days, 23 hours left to enroll

801 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