Ask a Question related to Macromedia Exchange Dreamweaver Extensions, Design and Development.
-
four-ks #1
File creation problems
Hi,
I'm pretty new at writing extensions so I'm quite certain my problem is a
mistake on my part.
I've written a piece of code that takes a data file and formats it into a
table and writes the table to a new file (the client doesn't want to use
templates, that's why it's done this way).
The data file is formatted with the first line as the page title, the second
line has the column names and the rest is the data. The data if formatted with
";"
The function doStuff calls the fixTag function.
Whenever I run this, the contents of the data file (opened with fh =
dreamweaver.openDocument(theFile); in the fixTag function) receives the data I
try to write to the new file (created with var newTableDoc =
dreamweaver.createXHTMLDocument(); in the doStuff function).
What am I doing wrong here. I've tried using dreamweaver.releaseDocument to
release the data file, but it doesn't help. I've tried creating the new file
with dreamweaver.getNewDocumentDOM but can't figure out how to then save that
without running into the same overwrite problem.
Any help, tips, and the like is greatly appreciated.
Problem code is attached.
function doStuff(){
var siteFocus,agree,chooseFiles,fileSelect;
var alertMessage = "";
var rString;
var siteSelectedArray = new Array();
var writeSiteSelectedArray = new Array();
var urlArray = new Array;
var siteFocus = site.getFocus();
urlArray = dw.getDocumentPath("document");
rString = fixTag(urlArray);
var newTableDoc = dreamweaver.createXHTMLDocument();
newTableDoc.getElementsByTagName("body")[0].innerHTML = rString;
// alert(newTableDoc.documentElement.outerHTML);
}
function fixTag(theFile,autoSave){
var fh;
var fileLines;
var splitLines = new Array;
var stateBody = new Array;
var stateName = "none";
var metaTags;
var repeated = "0";
var returnString="";
var pageHeading, tableHeadings, tableContent;
var tableEnd = "</table>\n";
fh = dreamweaver.openDocument(theFile); // Open the file for reading
fileLines = fh.documentElement.outerHTML.split("\n");
for (i = 1;i<fileLines.length;i++){
splitLines[i]=fileLines[i].split(";");
}
dreamweaver.releaseDocument(fh);
// heading of page
pageHeading = "<h1>" + fileLines[0] + "</h1>\n";
// Generate table header
tableHeadings = "<thead>\n<tr>\n";
for (i=1;i<splitLines[1].length;i++){
tableHeadings += "<th>" + splitLines[1][i] + "</th>\n";
}
tableHeadings += "</tr>\n</thead>\n";
for (i=2;i<splitLines.length-1;i++){
if (!stateBody[splitLines[i][0]]){
stateBody[splitLines[i][0]] = "";
}
stateBody[splitLines[i][0]] += "<tr>\n";
for (j=1;j<splitLines[i].length;j++){
stateBody[splitLines[i][0]] += "<td>" + splitLines[i][j] + "</td>\n";
}
stateBody[splitLines[i][0]] += "</tr>\n";
}
returnString += pageHeading;
for (i in stateBody){
returnString += "<table>\n <caption>" + i + "</caption>\n" + tableHeadings +
"<tbody>\n" + stateBody[i] + "</tbody>\n</table>\n";
}
return returnString;
}
four-ks Guest
-
XML File creation
I am generating xml output from a cfquery. <cfxml variable="Contact" casesensitive="yes"> <Contact> <cfoutput query="GetName"> <phonenum... -
Form creation problems
Hi I am trying to make a "create new user" form where people will enter their info to create a user name and password. The information would then... -
pdf creation problems
I am opperating on Win 2000 using freehand mx. I am trying to create a PDF file through Distiller (Acrobat 4.0). I save the freehand file as a eps... -
[Q] Image Creation problems & MacOSX
I've got a fairly simple php script which creates a simple gif image. Now, if I use this script on my primary webhost, everything works correctly... -
linux boot CD creation problems
Hi all, I have a dual boot machine (XP + RH 7.3). I have not installed any boot loaders and get into linux thru a boot floppy. (My boot sequence... -
four-ks #2
Re: File creation problems
Almost forgot some important details.
Dreamweaver MX 2004 running on win 2k system.
four-ks Guest
-
four-ks #3
Re: File creation problems
Found the solution. Was my poor coding.
I just need to have
dreamweaver.createXHTMLDocument();
newTableDoc=dreamweaver.getActiveWindow();
newTableDoc.getElementsByTagName("body")[0].innerHTML = rString;
hope this helps someone else.
Cheers.
four-ks Guest



Reply With Quote

