Hi Tom,
this my code,
actually,
I build up a list of vars from the recordset first, which I can also post if
you wish,
this takes roughly 2000 3000ms as there is quite a lot od string
manipulation going on,
but from here on takes well over 45000 ms,
<CFTRY>
<CFOBJECT
ACTION="CONNECT"
TYPE="COM"
CLASS="Microsoft.XMLDOM"
NAME="objXMLDOM">
<CFCATCH>
<CFOBJECT
ACTION="CREATE"
TYPE="COM"
CLASS="Microsoft.XMLDOM"
NAME="objXMLDOM">
</CFCATCH>
</CFTRY>
<CFSET AHNode=objXMLDOM.CreateElement("ActualHoursWorked")>
<CFSET HeadingNode=objXMLDOM.CreateElement("Heading")>
<CFSET MDRNode=objXMLDOM.CreateElement("MDR")>
<CFSET MDRNode.text="Multible Day Report">
<CFSET HeadingNode.AppendChild(MDRNode)>
<CFSET FROMNode=objXMLDOM.CreateElement("From")>
<CFSET
FROMNode.text="#UCASE(DATEFORMAT(LISTGETAT(DAYStringList,1),'dddd - dd -
mmmm - yyyy'))#">
<CFSET HeadingNode.AppendChild(FROMNode)>
<CFSET TONode=objXMLDOM.CreateElement("To")>
<CFSET
TONode.text="#UCASE(DATEFORMAT(LISTGETAT(DAYStringList,LISTLEN(DAYStringList
)),'dddd - dd - mmmm - yyyy'))#">
<CFSET HeadingNode.AppendChild(TONode)>
<CFSET AHNode.AppendChild(HeadingNode)>
<CFSCRIPT>
for(xi = 1; xi lte LISTLEN(DAYStringList); xi=xi+1){
//set global list containers for each day
TempStart = LISTGETAT(
GlobalStartList,xi,"|" );
TempEnd = LISTGETAT( GlobalEndList,xi,"|" );
TempLocationStart = LISTGETAT(
GlobalStartLocationList,xi,"|" );
TempLocationEnd = LISTGETAT(
GlobalEndLocationList,xi,"|" );
if( NOT LISTGETAT(
GlobalDailyJourney,xi,"|" ) CONTAINS("n/a") ){
TempGlobalDailyJourney =
LISTGETAT( GlobalDailyJourney,xi,"|");
}else{
TempGlobalDailyJourney="n/a:n/a;";
}
TEMPGlobalDailyTotal = LISTGETAT(
GlobalDailyTotal,xi,"|" );
TEMPDailyAverageList=LISTGETAT(
DailyAverageList,xi,"|" );
//start creating daily elements and adding
data
NewDay =
objXMLDOM.CreateElement("DailyReport");
//create attribute of DailyReport, Date.
newDayAtt =
objXMLDOM.createAttribute("Date");
newDayAtt.text = "#UCASE( DATEFORMAT(
LISTGETAT( DAYStringList,xi ),'dddd - dd - mmmm - yyyy' ) )#";
mapNode = NewDay.attributes;
mapNode.setNamedItem(newDayAtt);
for ( j = 1; j lte LISTLEN(
TempStart,";" ); j = j + 1 ){
//create journey node for
each individual report
JourneyNode =
objXMLDOM.CreateElement("Journey");
//create attribute of
Journey, No.
newAtt =
objXMLDOM.createAttribute("Number");
newAtt.text = "#j#";
namedNodeMap =
JourneyNode.attributes;
namedNodeMap.setNamedItem(newAtt);
//create local conatiners
for each daily journey
currStartTime = LISTGETAT(
TempStart,j,";" );
currEndTime = LISTGETAT(
TempEnd,j,";" );
currStartLocation =
LISTGETAT( TempLocationStart,j,";" );
currEndLocation = LISTGETAT(
TempLocationEnd,j,";" );
currDailyJourney =
LISTGETAT( TempGlobalDailyJourney,j,";" );
if( NOT
currDailyJourney CONTAINS( "n/a" ) ){
currDailyJourney = "#LISTGETAT( currDailyJourney,1,':' )# hr (s) #LISTGETAT(
currDailyJourney,2,':' )# mn (s) ";
}
//create sub node Journey
Start
JourneyStart =
objXMLDOM.CreateElement("StartTime");
if ( ISDATE(
currStartTime ) ){
JourneyStart.text = "#TIMEFORMAT(currStartTime,'hh:mm:tt')#";
}else{
JourneyStart.text = "#currStartTime#";
}
//append sub node to
JourneyNode
JourneyNode.AppendChild(JourneyStart);
//create sub node
StartLocation
StartLocation =
objXMLDOM.CreateElement("LocationStartPoint");
StartLocation.text =
"#currStartLocation#";
JourneyNode.AppendChild(StartLocation);
//create sub node Journey
End
JourneyEnd =
objXMLDOM.CreateElement("EndTime");
if( ISDATE(
currEndTime ) ){
JourneyEnd.text = "#TIMEFORMAT(currEndTime,'hh:mm:tt')#";
}else{
JourneyEnd.text = "#currEndTime#";
}
//append sub node to
JourneyNode
JourneyNode.AppendChild(JourneyEnd);
//create sub node
EndLocation
EndLocation =
objXMLDOM.CreateElement("LocationEndPoint");
EndLocation.text =
"#currEndLocation#";
JourneyNode.AppendChild(EndLocation);
//create sub node
JourneyDuration
JourneyDuration =
objXMLDOM.CreateElement("Duration");
JourneyDuration.text =
"#currDailyJourney#";
JourneyNode.AppendChild(JourneyDuration);
NewDay.AppendChild(JourneyNode);
if( j eq LISTLEN(
TempStart,";" ) ){
DailyDuration =
objXMLDOM.CreateElement("DailyDuration");
DailyDuration.text =
"#LISTGETAT( TEMPGlobalDailyTotal,1,':' )# hr (s) #LISTGETAT(
TEMPGlobalDailyTotal,2,':' )# mn (s)";
NewDay.AppendChild(DailyDuration);
DailyAverage =
objXMLDOM.CreateElement("DailyAverage");
DailyAverage.text =
"#LISTGETAT( TEMPDailyAverageList,1,':' )# hr (s) #LISTGETAT(
TEMPDailyAverageList,2,':' )# mn (s)";
NewDay.AppendChild(DailyAverage);
}
}
AHNode.AppendChild(NewDay);
if( xi eq LISTLEN(DAYStringList) ){
TotalHours =
objXMLDOM.CreateElement("TotalHoursWorked");
TotalHours.text = "#OAHour# hr (s)
#OAMin# mn (s)";
AHNode.AppendChild(TotalHours);
AVGForDuration =
objXMLDOM.CreateElement("DurationAverage");
AVGForDuration.text = "#OAAVGHour#
hr (s) #OAAVGMin# mn (s)";
AHNode.AppendChild(AVGForDuration);
}
}
</CFSCRIPT>
<CFSET AHNodeClose=objXMLDOM.AppendChild(AHNode)>
<CFSET XMLVersion=objXMLDOM.CreateProcessingInstruction("xml",
"version='1.0'")>
<CFSET objXMLDOM.InsertBefore(XMLVersion,AHNodeClose)>
Then I save the XML DOC to specified directory,
-----Original Message-----
From: tom dyson [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 10, 2002 6:06 PM
To: [EMAIL PROTECTED]
Subject: Re: [cf-xml] xml file taking over 40000 ms to create
Hi John
Send your code to the list, it's not OT at all.
I generally use ColdFusion string manipulation to build XML documents,
rather than MSXML or Xerces DOM methods: this is almost more efficient (but
may not be possible in your situation). As an extremely rough guideline, you
should be able to create 30 kb documents - by looping over the result set of
a database query, for example - in less than 200 ms.
Tom
> Greetings,
>
> We are using CF 5 here,
> I am wondering is there overheads when building quite a large XML doc,
> I have attached the document type that is being created to give an idea of
> its size,
>
> feel free to ridicule its structure maybe, I'm not an XML guru,
>
> the thing is, if there is no real overhead when creating larger xml
> documents,
> (in saying that they are only averaging 25.7 kb in size),
> would someone be open to looking at my scripting, maybe there is a bottle
> neck there,
>
> I don't want to send an OT post to the list, and I also respect that
> everyone is
> buisy, but if someone does want to take a look at it, I'll post you my
code,
>
> Respectfully,
>
> j
-----------------+
tom dyson
t: +44 (0)1608 811870
m: +44 (0)7958 752657
http://torchbox.com
-----------------------+
cf-xml mailing list
http://torchbox.com/xml/list.cfm
-----------------------+
cf-xml mailing list
http://torchbox.com/xml/list.cfm