Sagewire Logo

XML Syntax Error

4 Message(s) by 4 Author(s) originally posted in cfml discussion


From: kodemonki Date:   Wednesday, October 24, 2007
I have a page with NO comments that output unicode in xml and sometimes it
works, sometimes it says:
Incorrect syntax was used in a comment. Error processing resource
'http://www.netspeaknow.com/gamers/flashCFM/getPopQuiz.cf...

<!-- " ---></TD></TD></TD></TH></TH></TH></TR></TR></TR></TA...

but there are no comments. Even if there were why'd this page only work
about half the time? I have attached the code .

Thanks for any help!

<CFSETTING showdebugoutput="false">

<CFCONTENT type="text/xml; charset=utf-8" reset="true"><CFPROCESSINGDIRECTIVE
pageencoding="utf-8" suppresswhitespace="Yes">

<CFSCRIPT>
function ListRandomElements(theList, numElements) {
var theDelim = ",";
var final_list = "";
var x = 0;
var random_i = 0;
var random_val = 0;
if(ArrayLen(Arguments) GTE 3) theDelim = Arguments[3];
if(numElements GT ListLen(theList, theDelim)) {
numElements = ListLen(theList, theDelim);
}
for(x=1; x LTE numElements; x=x+1){
random_i = RandRange(1, ListLen(theList),"SHA1PRNG");
random_val = ListGetAt(theList, random_i);
theList = ListDeleteAt(theList, random_i);
final_list = ListAppend(final_list, random_val , theDelim);
}
return(final_list);
}
</CFSCRIPT>
<CFFUNCTION name="getPhonetic" returntype="string">
<CFARGUMENT name="myDisplayID" type="numeric" required="yes">
<CFQUERY name="theWord" data source="langDB">
Select phonetic, Definition from LessonWords
Where recID = #Arguments.myDisplayID#
</CFQUERY>
<CFOUTPUT query="theWord">
<CFSET myWord = #phonetic# & " " & #definition#>
</CFOUTPUT>
<CFRETURN myWord>
</CFFUNCTION>
<CFQUERY name="get_pop_quiz" datasource="langDB">
SELECT uws.lessonWordID
FROM UserWordScore uws, lessonWords lw, users u
WHERE uws.userID = #ListGetAt(GetAuthUser(),1)#
AND wordScore > 1
AND lw.recID = uws.lessonWordID
AND lw.lessonPlanID = u.lastLessonID
ORDER BY wordScore DESC
</CFQUERY>
<CFIF get_pop_quiz.RecordCount LT 7>
<CFXML variable ="rawXML">
<popquiz avail="no"/>
</CFXML>
<CFELSE>
<CFSET myArray = ArrayNew(1)>
<CFSET myArray2 = ArrayNew(1)>
<CFSET myArray3 = ArrayNew(1)>
<CFSET myTmpArray = ArrayNew(1)>
<CFSET myWordIDs = ArrayToList(myArray,",")>
<CFSET myRndIDs = ArrayToList(myArray2,",")>
<CFSET myQuizGrp = ArrayToList(myArray3,",")>
<CFSET masterWordList = ArrayToList(myArray3,",")>
<CFSET x = 1>
<CFOUTPUT>
<CFLOOP query="get_pop_quiz">
<CFSET myWordIDs = ListAppend(myWordIDs,"#lessonWordID#")>
<CFIF x EQ 7>
<CFBREAK>
</CFIF>
<CFSET x = x + 1>
</CFLOOP>
</CFOUTPUT>
<CFSET masterWordList = #myWordIDs#>
<CFQUERY name="theWord" datasource="langDB">
SELECT recID, LessonWords.displayWord, LessonWords.definition,
LessonMP3.filePath
FROM LessonWords INNER JOIN LessonMP3 ON LessonWords.sndID = LessonMP3.sndID
Where recID in (#masterWordList#)
</CFQUERY>
<CFXML variable="rawXML">
<popquiz avail="yes">
<words> <CFOUTPUT query="theWord"><CFSET pos = RandRange(1,8,"SHA1PRNG")>
<word id="#recId#" value="#displayWord#" answer="#pos#"
sound="#filepath#">
<CFSET myRndIDs = #masterWordList#><CFSET myRndIDs =
ListDeleteAt(myRndIDs,ListFind(myRndIDs,#recID#))>
<CFSET myQuizGrp =
#ListRandomElements(myRndIDs, 8)#>
<CFSET myQuizGrp =
ListSetAt(myQuizGrp,#pos#,#recID#)>
<CFLOOP list="#myQuizGrp#" index="x">
<answer spelling="#getPhonetic(x)#"/></CFLOOP>
</word></CFOUTPUT>
</words>
</popquiz>
</CFXML>
</CFIF>
<CFFILE action="write" output="#tostring(rawxml)#"
file="#getdirectoryfrompath(getcurrenttemplatepath())#getPopQuiz.xml">

<CFOUTPUT>#toString(rawXML)#</CFOUTPUT>
</CFPROCESSINGDIRECTIVE>


From: GArlington Date:   Thursday, October 25, 2007
wrote in message:
I have a page with NO comments that output unicode in xml and sometimes it
works, sometimes it says:
Incorrect syntax was used in a comment. Error processing resource
'http://www.netspeaknow.com/gamers/flashCFM/getPopQuiz.cf...
<!-- " ---></TD></TD></TD></TH></TH></TH></TR></TR></TR></TA...



This line above does show a comment. It may be a ColdFusion error that adds
the comments and then your XML processor tries to interpret the
errored page as if it was valid (or invalid) XML. You should check the
page status (see headers) before you start processing XML...

but there are no comments. Even if there were why'd this page only work
about half the time? I have attached the code.
Thanks for any help!
<CFSETTING showdebugoutput="false">
<CFCONTENT type="text/xml; charset=utf-8" reset="true"><CFPROCESSINGDIRECTIVE
pageencoding="utf-8" suppresswhitespace="Yes">

<CFSCRIPT>
function ListRandomElements(theList, numElements) {
var theDelim = ",";
var final_list = "";
var x = 0;
var random_i = 0;
var random_val = 0;
if(ArrayLen(Arguments) GTE 3) theDelim = Arguments[3];
if(numElements GT ListLen(theList, theDelim)) {
numElements = ListLen(theList, theDelim);
}
for(x=1; x LTE numElements; x=x+1){
random_i = RandRange(1, ListLen(theList),"SHA1PRNG");
random_val = ListGetAt(theList, random_i);
theList = ListDeleteAt(theList, random_i);
final_list = ListAppend(final_list, random_val , theDelim);
}
return(final_list);
}
</CFSCRIPT>
<CFFUNCTION name="getPhonetic" returntype="string">
<CFARGUMENT name="myDisplayID" type="numeric" required="yes">
<CFQUERY name="theWord" datasource="langDB">
Select phonetic, Definition from LessonWords
Where recID = #Arguments.myDisplayID#
</CFQUERY>
<CFOUTPUT query="theWord">
<CFSET myWord = #phonetic# & " " & #definition#>
</CFOUTPUT>
<CFRETURN myWord>
</CFFUNCTION>
<CFQUERY name="get_pop_quiz" datasource="langDB">
SELECT uws.lessonWordID
FROM UserWordScore uws, lessonWords lw, users u
WHERE uws.userID = #ListGetAt(GetAuthUser(),1)#
AND wordScore > 1
AND lw.recID = uws.lessonWordID
AND lw.lessonPlanID = u.lastLessonID
ORDER BY wordScore DESC
</CFQUERY>
<CFIF get_pop_quiz.RecordCount LT 7>
<CFXML variable="rawXML">
<popquiz avail="no"/>
</CFXML>
<CFELSE>
<CFSET myArray = ArrayNew(1)>
<CFSET myArray2 = ArrayNew(1)>
<CFSET myArray3 = ArrayNew(1)>
<CFSET myTmpArray = ArrayNew(1)>
<CFSET myWordIDs = ArrayToList(myArray,",")>
<CFSET myRndIDs = ArrayToList(myArray2,",")>
<CFSET myQuizGrp = ArrayToList(myArray3,",")>
<CFSET masterWordList = ArrayToList(myArray3,",")>
<CFSET x = 1>
<CFOUTPUT>
<CFLOOP query="get_pop_quiz">
<CFSET myWordIDs = ListAppend(myWordIDs,"#lessonWordID#")>
<CFIF x EQ 7>
<CFBREAK>
</CFIF>
<CFSET x = x + 1>
</CFLOOP>
</CFOUTPUT>
<CFSET masterWordList = #myWordIDs#>
<CFQUERY name="theWord" datasource="langDB">
SELECT recID, LessonWords.displayWord, LessonWords.definition,
LessonMP3.filePath
FROM LessonWords INNER JOIN LessonMP3 ON LessonWords.sndID = LessonMP3.sndID
Where recID in (#masterWordList#)
</CFQUERY>
<CFXML variable="rawXML">
<popquiz avail="yes">
<words> <CFOUTPUT query="theWord"><CFSET pos = RandRange(1,8,"SHA1PRNG")>
<word id="#recId#" value="#displayWord#" answer="#pos#"
sound="#filepath#">
<CFSET myRndIDs = #masterWordList#><CFSET myRndIDs =
ListDeleteAt(myRndIDs,ListFind(myRndIDs,#recID#))>
<CFSET myQuizGrp =
#ListRandomElements(myRndIDs, 8)#>
<CFSET myQuizGrp =
ListSetAt(myQuizGrp,#pos#,#recID#)>
<CFLOOP list="#myQuizGrp#" index="x">
<answer spelling="#getPhonetic(x)#"/></CFLOOP>
</word></CFOUTPUT>
</words>
</popquiz>
</CFXML>
</CFIF>
<CFFILE action="write" output="#tostring(rawxml)#"
file="#getdirectoryfrompath(getcurrenttemplatepath())#getPopQuiz.xml">

<CFOUTPUT>#toString(rawXML)#</CFOUTPUT>


> </CFPROCESSINGDIRECTIVE>


From: dacf Date:   Friday, October 26, 2007
Turn Cold Fusion Debugging off...
Or put <CFSETTING showDebugOutput="false"/> at the top of the page
Also, put a <CFCONTENT reset="true"/> at your last link where you toString
your XML variable and <cfabort/> directly after that last line.


From: Adam Cameron Date:   Friday, October 26, 2007
Try wrapping all your code in <CFSILENT>, and move you <CFCONTENT> down to
the same line you're outputting your XML (ie: at the bottom).

XML gets antsy if there is whitespace before the <?xml?> tag , or between
that and the doctype (in my experience).

I'd alos SERIOUSLY consider refactoring your approach to writing code so
that you do not have a mix of processing, function declarations, DB calls
and output all in the same CFM template. It's a bit of a mess.

Also make sure you VAR all your variables in functions, and use
<CFQUERYPARAM> tags in your queries. Read up on when to use pound signs
(and when not to), and when to use <CFOUTPUT>.

You only need pageencoding="UTF-8" on your template if the actual code has
UTF-8 characters in it: it does not matter if the DATA you're processing is
UTF-8; the <CFPROCESSINGDIRECTIVE> tag is a compiler instruction, not a
ruuntime one. Otherwise it's just noise (cue: Paul Hatings disagreeing
with that ;-)

--
Adam



Next Message: change server root to outside directory


Blogs related to XML Syntax Error

Syntax
Date: October 10th, 2007 02:07 PM - septemberq - Form to Email Syntax Error? Post: Hello and thank you for your help. I am new to ASP. Can someone tell me whats wrong with the syntax of this script? Thank you [code] New Page 1 Success . ...

CFCUnit javax/xml/xpath/XPathExpressionException error
Finally got it working. I wasn't able to reproduce the error, but it was obviously a syntax problem in my build.xml file. I'm posting this in case anyone is looking for a sample build.xml file for CFCUnit. This is what worked for me. ...

invalid mapped update
... invalid token invalid token c invalid token coldfusion invalid token in invalid token in class invalid token in class struct invalid token in class struct or interface member declaration invalid token in expression invalid token xml ...

coldfusion dynamic menu
coldfusion dynamic form coldfusion dynamic forms coldfusion dynamic menu coldfusion dynamic menus coldfusion dynamic queries coldfusion dynamic query coldfusion dynamic variable coldfusion dynamic variable name coldfusion dynamic ...

invalid program file name
... syntax invalid syntax error invalid syntax error 96 microsoft internet explorer invalid syntax error explorer invalid syntax error fix invalid syntax error ie invalid syntax error ie 6 invalid syntax error ie6 invalid syntax error ...

error fix oe
... error in ws2_32 dll error in wzcdlg dll error in xml error in xml document error in xml document 0 0 error in xp error in xp spool directroy selection error in your sql error in your sql syntax error in your sql syntax near error ...


Programming | Sports | Autos

copyright 2006
Valid XHTML 1.0 Transitional