Here's what I'd like to do, I'm using a VB .Net script to transform a XML file using a XSL file into a HTML file with two checkboxes for each row of "Server Name" data from the XML file. Now, the transformation works great I get my two checkboxes, but now I want to take it a step further.
When a user checks a checkbox I want to write the information from the "id" of the checkbox to a text file. If the user unchecks the checkbox it would then remove that entry from the text file. And then have a "body onload" to pull data from the text file and check the boxes that are supposed to be checked when the web page is re-loaded.
I hope I'm explaining this correctly. is this possible, I know it will cause an error (ActiveX) when writing to the text file on a server.
Thanks
My XSL file below:
My XML file below:
Here is the HTML page that was created:
When a user checks a checkbox I want to write the information from the "id" of the checkbox to a text file. If the user unchecks the checkbox it would then remove that entry from the text file. And then have a "body onload" to pull data from the text file and check the boxes that are supposed to be checked when the web page is re-loaded.
I hope I'm explaining this correctly. is this possible, I know it will cause an error (ActiveX) when writing to the text file on a server.
Thanks
My XSL file below:
Code:
<xsl:stylesheet version="1.0" xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform">[/URL]
<xsl:output method="html" indent="yes" />
<xsl:template match="/">
<SCRIPT LANGUAGE="javascript">
<![CDATA[
var password='theirpassword';
var name='username';
function WriteToFile() {
var filename = '//ho/dfs01/work/IS/Operations/GROUP0K/Automation/temp.txt';
var fso = new ActiveXObject('Scripting.FileSystemObject');
if (fso.FileExists(filename)) {
var a, ForAppending, file;
ForAppending = 8;
file = fso.OpenTextFile(filename, ForAppending, false);
file.WriteLine(name);
file.WriteLine(password);
}
else {
var file = fso.CreateTextFile(filename, true);
file.WriteLine(password);
file.WriteLine(name);
}
file.Close();
}
function ReadIt() {
var filename = '//ho/dfs01/work/IS/Operations/GROUP0K/Automation/temp.txt';
var fso, a, ForReading;
ForReading = 1;
fso = new ActiveXObject('Scripting.FileSystemObject');
file = fso.OpenTextFile(filename, ForReading, false);
var name = file.readline();
var password = file.readline();
file.Close();
}
]]>
</SCRIPT>
<HTML>
<HEAD>
<style type="text/css">
BODY {margin:0; background-color="ivory"}
H1 {font:bold 18pt Verdana; margin-top:1em; color:"#8b0000"}
DIV {font:bold; font-size:11px;height:20px}
pre {word-wrap:break-word;font-family: arial,san-serif;margin-top:2px;margin-bottom:2px;font-size:11px;font-weight:bold}
</style>
</HEAD>
<!-- Start of HTML Body -->
<BODY>
<H1 align="center">
<xsl:value-of select="UMZ/description"/>
</H1>
<DIV id="listing">
<xsl:apply-templates select="UMZ"/>
</DIV>
</BODY>
<!-- End of HTML Body -->
</HTML>
</xsl:template>
<!-- Start of Templates -->
<xsl:template match="UMZ">
<TABLE width="100%" border="1" borderColor="black" valign="TOP" align="center">
<TR bgColor="#cccccc" borderColorDark="black" borderColorLight="black">
<TD>
<font color="purple">
<DIV align="center">Pre</DIV>
</font>
</TD>
<TD>
<font color="purple">
<DIV align="center">Post</DIV>
</font>
</TD>
<TD>
<font color="purple">
<DIV align="center">Server Name</DIV>
</font>
</TD>
<TD>
<font color="purple">
<DIV align="center">Pre-Client/Server</DIV>
</font>
</TD>
<TD>
<font color="purple">
<DIV align="center">Post-Client/Server</DIV>
</font>
</TD>
<TD>
<font color="purple">
<DIV align="center">Pre-MVS</DIV>
</font>
</TD>
<TD>
<font color="purple">
<DIV align="center">Post-MVS</DIV>
</font>
</TD>
<TD>
<font color="purple">
<DIV align="center">Misc. Instructions</DIV>
</font>
</TD>
</TR>
<xsl:for-each select="Server">
<xsl:sort order="ascending" select="@name"/>
<TR bgColor="#f0f0f0">
<td><DIV align="center">
<input type="checkbox" onClick="WriteToFile()">
<xsl:attribute name="id">pre
<xsl:value-of select="@name"/>
</xsl:attribute>
</input></DIV>
</td>
<td> <DIV align="center">
<input type="checkbox" onClick="WriteToFile()">
<xsl:attribute name="id">post
<xsl:value-of select="@name"/>
</xsl:attribute>
</input></DIV>
</td>
<TD>
<DIV align="center">
<font color="red">
<xsl:value-of select="@name"/>
</font>
</DIV>
</TD>
<TD>
<DIV align="center">
<xsl:call-template name="tTextParser">
<xsl:with-param name="pText" select="PreCS/text()"/>
</xsl:call-template>
</DIV>
</TD>
<TD>
<DIV align="center">
<xsl:call-template name="tTextParser">
<xsl:with-param name="pText" select="PostCS/text()"/>
</xsl:call-template>
</DIV>
</TD>
<TD>
<DIV align="center">
<xsl:call-template name="tTextParser">
<xsl:with-param name="pText" select="PreMVS/text()"/>
</xsl:call-template>
</DIV>
</TD>
<TD>
<DIV align="center">
<xsl:call-template name="tTextParser">
<xsl:with-param name="pText" select="PostMVS/text()"/>
</xsl:call-template>
</DIV>
</TD>
<TD>
<DIV align="center">
<xsl:call-template name="tTextParser">
<xsl:with-param name="pText" select="Misc/text()"/>
</xsl:call-template>
</DIV>
</TD>
</TR>
</xsl:for-each>
</TABLE>
</xsl:template>
<xsl:template name="tTextParser">
<xsl:param name="pText"/>
<pre><xsl:value-of select="$pText"/></pre>
</xsl:template>
</xsl:stylesheet>
My XML file below:
Code:
<?xml version="1.0" standalone="yes"?>
<UMZ>
<description>UMZ Listing</description>
<Server name="ackbar01">
<PreCS>N/A</PreCS>
<PostCS>N/A</PostCS>
<PreMVS>N/A</PreMVS>
<PostMVS>N/A</PostMVS>
<Misc>N/A</Misc>
</Server>
<Server name="ben01">
<PreCS>N/A</PreCS>
<PostCS>N/A</PostCS>
<PreMVS>N/A</PreMVS>
<PostMVS>N/A</PostMVS>
<Misc>N/A</Misc>
</Server>
<Server name="alderaan">
<PreCS>personelMondayAM1</PreCS>
<PostCS>personelMondayAM2</PostCS>
<PreMVS>Shutdown task:
DBSYREPO on TST2</PreMVS>
<PostMVS>Startup task:
DBSYREPO on TST2</PostMVS>
<Misc>N/A</Misc>
</Server>
</UMZ>
Here is the HTML page that was created:
Code:
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=utf-16">
<style type="text/css">
BODY {margin:0; background-color="ivory"}
H1 {font:bold 18pt Verdana; margin-top:1em; color:"#8b0000"}
DIV {font:bold; font-size:11px;height:20px}
pre {word-wrap:break-word;font-family: arial,san-serif;margin-top:2px;margin-bottom:2px;font-size:11px;font-weight:bold}
</style>
</HEAD>
<BODY>
<H1 align="center">UMZ Listing</H1>
<DIV id="listing">
<TABLE width="100%" border="1" borderColor="black" valign="TOP" align="center">
<TR bgColor="#cccccc" borderColorDark="black" borderColorLight="black">
<TD>
<font color="purple">
<DIV align="center">Pre</DIV>
</font>
</TD>
<TD>
<font color="purple">
<DIV align="center">Post</DIV>
</font>
</TD>
<TD>
<font color="purple">
<DIV align="center">Server Name</DIV>
</font>
</TD>
<TD>
<font color="purple">
<DIV align="center">Pre-Client/Server</DIV>
</font>
</TD>
<TD>
<font color="purple">
<DIV align="center">Post-Client/Server</DIV>
</font>
</TD>
<TD>
<font color="purple">
<DIV align="center">Pre-MVS</DIV>
</font>
</TD>
<TD>
<font color="purple">
<DIV align="center">Post-MVS</DIV>
</font>
</TD>
<TD>
<font color="purple">
<DIV align="center">Misc. Instructions</DIV>
</font>
</TD>
</TR>
<TR bgColor="#f0f0f0">
<td>
<DIV align="center">
<input type="checkbox" id="pre
ackbar01">
</DIV>
</td>
<td>
<DIV align="center">
<input type="checkbox" id="post
ackbar01">
</DIV>
</td>
<TD>
<DIV align="center">
<font color="red">ackbar01</font>
</DIV>
</TD>
<TD>
<DIV align="center">
<pre>N/A</pre>
</DIV>
</TD>
<TD>
<DIV align="center">
<pre>N/A</pre>
</DIV>
</TD>
<TD>
<DIV align="center">
<pre>N/A</pre>
</DIV>
</TD>
<TD>
<DIV align="center">
<pre>N/A</pre>
</DIV>
</TD>
<TD>
<DIV align="center">
<pre>N/A</pre>
</DIV>
</TD>
</TR>
<TR bgColor="#f0f0f0">
<td>
<DIV align="center">
<input type="checkbox" id="pre
alderaan">
</DIV>
</td>
<td>
<DIV align="center">
<input type="checkbox" id="post
alderaan">
</DIV>
</td>
<TD>
<DIV align="center">
<font color="red">alderaan</font>
</DIV>
</TD>
<TD>
<DIV align="center">
<pre>personelMondayAM1</pre>
</DIV>
</TD>
<TD>
<DIV align="center">
<pre>personelMondayAM2</pre>
</DIV>
</TD>
<TD>
<DIV align="center">
<pre>Shutdown task:
DBSYREPO on TST2</pre>
</DIV>
</TD>
<TD>
<DIV align="center">
<pre>Startup task:
DBSYREPO on TST2</pre>
</DIV>
</TD>
<TD>
<DIV align="center">
<pre>N/A</pre>
</DIV>
</TD>
</TR>
<TR bgColor="#f0f0f0">
<td>
<DIV align="center">
<input type="checkbox" id="pre
ben01">
</DIV>
</td>
<td>
<DIV align="center">
<input type="checkbox" id="post
ben01">
</DIV>
</td>
<TD>
<DIV align="center">
<font color="red">ben01</font>
</DIV>
</TD>
<TD>
<DIV align="center">
<pre>N/A</pre>
</DIV>
</TD>
<TD>
<DIV align="center">
<pre>N/A</pre>
</DIV>
</TD>
<TD>
<DIV align="center">
<pre>N/A</pre>
</DIV>
</TD>
<TD>
<DIV align="center">
<pre>N/A</pre>
</DIV>
</TD>
<TD>
<DIV align="center">
<pre>N/A</pre>
</DIV>
</TD>
</TR>
</TABLE>
</DIV>
</BODY>
</HTML>