BizTalk Utilities CV ,   Jobs ,   Code library  
 
 

The asp code to produce the XSL demos

Click here for an explanation
<% LANGUAGE="VBSCRIPT" %>
<%
'objMainXML contains the details of the demo as defined in examples.xml
	set objMainXML=Server.CreateObject("microsoft.xmldom")
	
'objXML contains the XML of the particular demo being viewed
	set objXML= Server.CreateObject("microsoft.xmldom")	

'objXSL contains the chosen XSL stylesheet of the particular demo being viewed
	set objXSL= Server.CreateObject("microsoft.xmldom")	

'Use the default stylesheet provided by MSXML to display XML & XSL file
	set objDefaultXSL=createObject ("microsoft.xmldom")

'This is found in the msxml dll and is accessed by
	objDefaultXSL.load("res://msxml.dll/defaultss.xsl")


'exampleID holds the ID of the demo to be viewed
'If no ID is given then show the first one
	exampleID=Request.QueryString("id")
	if isempty(exampleID) then
		exampleID="1"
	end if


'XSLid contains the ID of the stylesheet to be used
'If no id is given then use the first one
	XSLid=Request.QueryString("xsl")
	if isempty(XSLid) then
		XSLid="1"
	end if


'Load examples.xml into objMainXML
	objMainXML.async=False
	objMainXML.load(server.MapPath("examples.xml"))


'Find the example node with the required ID 
	set objExamples=objMainXML.documentElement
	Set demo = objExamples.selectSingleNode("example[@id=" & exampleID & "]")


'XMLfile contains the name of the example XML file to be used e.g Sales.xml
	XMLFile=demo.selectSingleNode("xmlFile").text


'XSLexamples contains the nodes of each of the XSL examples
	set XSLexamples=demo.selectNodes("XSLexample")
	

'Calculate the links for each example
'xslLinksHTML is one string which contains the HTML for all the links
'e.g "<a href=examples.asp?id=1&xsl=1>example1</a> <a href=examples.asp?id=1&xsl=2>example2</a>"

'loop araound each XSL example and create link.
'The querystring attached to the link consists of
' ID - The ID of the demo
' XSL - The ID of the XSL stylesheet to be used
' XML - A flag indicating if the XML is to be displayed. If this equals 1 then display the XML. if it is empty then display the XSL.
	
	xslLinksHTML=""
	for each example in XSLexamples		
		xslLinksHTML=xslLinksHTML & "<a href=examples.asp?id=" &exampleID &"&xsl=" &example.getAttribute("id") & ">"
		xslLinksHTML=xslLinksHTML & example.getAttribute("desc") & "</a> "
		
'While were looping through the example XSL's check to see if we're at the requested XSL
'If we are then get the relevant details ready to display	

		if XSLid=example.getAttribute("id") then 
			XSLfile=example.selectSingleNode("xslFile").text
			message="<b><font face=Verdana size=2>" &example.selectSingleNode("xslTextTitle").text & "</font></b></br>" &vbCRLF
			messageText=replace(example.selectSingleNode("xslText").text,"<","<")
			messageText=replace(messageText,">",">")
			message=message & messageText & "<p>"
		end if
	next

'Add the link to display the XML file. 
'This need a reference to the current demo, the current XSL and set the XML flag to "1"
	xslLinksHTML=xslLinksHTML & "<a href=examples.asp?id=" &exampleID &"&xsl=" &XSLid &"&xml=1>View XML</a>"

'Get header text for the demo
	headerText="<h3>" & demo.selectSingleNode("Title").text &" by "
	headerText=HeaderText & "<a href=mailto:" & demo.selectSingleNode("email").text &">"
	headerText=headertext & demo.selectSingleNode("Author").text &"</a></h3>"
	headerText=headerText & "<font face=Verdana size=2>" & demo.selectSingleNode("heading").text &"</font>"
	
'Load the relevant XML and XSL into object objXML & objXSL respectively
	objXML.async=False
	objXSL.async=False
	objXML.load(Server.MapPath(XMLfile))
	objXSL.load(Server.MapPath(XSLFile))

'transformedHTML contains the result of the XSL transformation on the XML
	transformedHTML=objXML.transformNode(objXSL.documentElement)

'Check if the XML file is to be displayed
'Keep the current xsl if it is
	displayFile=Request.QueryString("xml")
	if isempty(displayFile) then
		displayFile="XSL Stylesheet:" & XSLfile
'Transform the stylesheet to be displayed using MSXML's default stylesheet
		displayHTML=objXSL.transformNode(objDefaultXSL.documentElement)
	else
		displayFile="XML file:" & XMLfile
'Transform the XML to be displayed using MSXML's default stylesheet
		displayHTML=objXML.transformNode(objDefaultXSL.documentElement)
	end if
%>
<HTML>
<HEAD>
<title>TopXML : Sales Figures</TITLE>
    <!--#INCLUDE VIRTUAL="includes/includecss.asp"-->
    <% includecss("../../../") %>
</head>

<body>
<!--#INCLUDE VIRTUAL="/includes/top.asp"-->

<p> </p>
<%=headerText%>
<p> </p>


<p><b>Requirements:</font></b><span style="mso-spacerun: yes"> 
IE5 (or IE4 with the MSXML patch)</p>


<TABLE cellspacing=0 bordercolor=black border=1>
	<tbody>
		<tr valign="top">
			<td height="50" width="50%" align="center" bgcolor=khaki>
				<h3>Examples</h3>
                <p><font size="2">Click on one of this links to see the table content change,<br>
                which is being loaded from an XSL file.</font></p>
<!-- Display the links for the example XSL's -->
				<%=xslLinksHTML%>
				<br/>	
			</td>

			<td rowspan="3"  nowrap width="50%">
<!-- Display the name of the file that is being displayed -->
				<h3><%=displayFile%></h3>
	
				<font size=3>
<!-- Display the result of the default transformation on the XSL or XML -->
					<%=displayHTML%>
				</font>
			</td>
		</tr>
		<tr>
			<td align="center">
<!-- Diplay the result of the transformation of the XML with the relevant XSL -->
				<%=transformedHTML%>
			</tr>

		<tr>
			<td height="1000" valign="top" bgcolor=lightgoldenrodyellow>
<!-- Display the text of the example -->
				<pre><%=message%></pre>
			</td>
		</tr>
	</tbody>
</table>

<p
><br>
Coming soon is a follow-on from this article, where Andrew demonstrates how he
dynamically generated <br>this article using XML.</p>

<p
> </p>

<p
>
<font face="Verdana" size="2"><i>Andrew is a database and ASP designer/programmer for the University of Glamorgan, near Cardiff, Wales.  He is also studying a Masters degree in Advanced Information Systems, where his dissertation is a study on 'Using XML in
dynamically generated web pages to enhance the distance learning environment.', thus his interest in XML/XSL.  Other XML projects that Andrew has designed include a newsfeed page using Moreover.com, an XML/XSL based discussion board and an XML generating ASP page.</i></font></p>

<!--#INCLUDE VIRTUAL="/includes/footer.asp"-->
</BODY>
</HTML>

 

Recent Jobs

Integration Specialist Needed - Wor
Virtualization Server Infrastructur
A great opportunity to Digital Vide
here is a greate opportunity as a S
A great opportunity as a Network En

View all Jobs (Add yours)
View all CV (Add yours)




Chicago Web Site Design
conference call
help desk support
Bvlgari sunglasses
air freshener
odor remover


    Email TopXML  

Front Page Daily Stuff TopXML Forum XML blogs XML Newsgroups BizTalk Biztalk Utilities Biztalk Utilities Tutorial B2B SAP XML Microsoft .NET Dotnet System XML Soapformatter SQLXML XMLserializer XQuery PHP PHP SimpleXML PHP XML Dom PHP XML RPC PHP XSLT Java Java Java XML Xalan Microsoft ASP ASP Schemas XML SQL Server XML XMLDom XSL XSL Tutorial XSLT Stylesheets General Javascript CSS XHTML WAP