Solved

server variables in XSL

Posted on 2000-05-04
3
483 Views
Last Modified: 2006-11-17
is there any way to access global or server variables in XSL scripting
0
Comment
Question by:tommyh
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 50 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
xml xsd validation free tool to download 10 76
Formatting an Excel formula to give correct date format 4 72
json format text only 4 75
Change to event 1 100
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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

914 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now