Solved

server variables in XSL

Posted on 2000-05-04
3
479 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
Comment Utility
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
Comment Utility
is this relevant to asp and msxml parser?, and what about server variables?
0
 

Accepted Solution

by:
youngpup earned 50 total points
Comment Utility
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

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, …
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.
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: …
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

744 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

15 Experts available now in Live!

Get 1:1 Help Now