Link to home
Start Free TrialLog in
Avatar of rrattie
rrattieFlag for United States of America

asked on

Context validation error for tag cfif outputting to an XML file.

I'm getting the following error when trying to output to an XML file.

Error Occurred While Processing Request  
Context validation error for tag cfif.  
The start tag must have a matching end tag. An explicit end tag can be provided by adding </cfif>. If the body of the tag is empty you can use the shortcut <cfif .../>.
The CFML compiler was processing:

The body of a cfoutput tag beginning on line 118, column 20.
 
 
The error occurred in E:\intranet\cf_portal\ServiceResults.cfm: line 135
 
133 :     <dollar> $#trim(Form.txtDollar)#</dollar>
134 :     <recommendedvendor>
135 :       <cfif #Form.recVendorName# EQ "">
136 :         <cfelseif (IsDefined ("Form.recVendorName"))>
137 :         <recvendorname> #trim(FORM.recVendorName)#</recvendorname>
 
The code in question is below.  Any thoughts? The end cfif tag is plainly visible.. what am I missing?
<recommendedvendor>
      <cfif #Form.recVendorName# EQ "">
        <cfelseif (IsDefined ("Form.recVendorName"))>
        <recvendorname> #trim(FORM.recVendorName)#</recvendorname>
        <revdendorpoc>#trim(FORM.recVendorPOC)#</revdendorpoc>
        <recvendoremail>#trim(FORM.recVendorEmail)#</recvendoremail>
        <recvendorphone>#trim(FORM.recVendorPhone)#</recvendorphone>
        <recvendoraddress>#trim(FORM.recVendorAddress)# #trim(FORM.recVendorAddressCity)#,#trim(FORM.recVendorAddressState)# #trim(FORM.recVendorAddressZipcode)#</recvendoraddress>
        <cfelseif #Form.recVendorName2# EQ "">
        <cfelseif (IsDefined ("Form.recVendorName2"))>
        <recvendorname2> #trim(FORM.recVendorName2)#</recvendorname2>
        <revdendorpoc2>#trim(FORM.recVendorPOC2)#</revdendorpoc2>
        <recvendoremail2>#trim(FORM.recVendorEmail2)#</recvendoremail2>
        <recvendorphone2>trim(FORM.recVendorPhone2)#</recvendorphone2>
        <recvendoraddress2>#trim(FORM.recVendorAddress2)# #trim(FORM.recVendorAddressCity2)#,#trim(FORM.recVendorAddressState2)# #trim(FORM.recVendorAddressZipcode2)#</recvendoraddress2>
        <cfelseif #Form.recVendorName3# EQ "">
        <cfelse>
        <recvendorname3> #trim(FORM.recVendorName3)#</recvendorname3>
        <revdendorpoc3>#trim(FORM.recVendorPOC3)#</revdendorpoc3>
        <recvendoremail3>#trim(FORM.recVendorEmail3)#</recvendoremail3>
        <recvendorphone3>#trim(FORM.recVendorPhone3)#</recvendorphone3>
        <recvendoraddress3>#trim(FORM.recVendorAddress3)# #trim(FORM.recVendorAddressCity3)#,#trim(FORM.recVendorAddressState3)# #trim(FORM.recVendorAddressZipcode3)#</recvendoraddress3>
      </cfif>
    </recommendedvendor>

Open in new window

Avatar of azadisaryev
azadisaryev
Flag of Hong Kong image

i suspect the error is not ON line 135 - it is somewhere before it in the code where you actially did forget to put a closing </cfif> tag for some previous cfif block.

but on a non-related subject: what sort of code is:
<cfif #Form.recVendorName# EQ "">
        <cfelseif (IsDefined ("Form.recVendorName"))>
and the rest of <cfelseif> blocks in your posted snippet???

this code makes NO sense at all:
if Form.recVendorName is an empty string it IS already defined - no point checking for isdefined("Form.recVendorName") AFTER that! same for the rest of your <cfelseif> blocks.

Azadi
ASKER CERTIFIED SOLUTION
Avatar of Tomarse111
Tomarse111
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
good eyes, Tomarse111! but i doubt that missing # is the culprit: cf checks the code top-down, and since it broke on line 135 (or line 2 in posted snippet), it has not reached the missing # yet...

Azadi
I'm 99% sure that the missing # is the problem. Just tested it on a fake form submission with and without and it comes up with the same error and then fixes it.

Also point taken about his code not making sense. Please see attached:
<recommendedvendor>
<cfif IsDefined ("Form.recVendorName") AND Form.recVendorName NEQ "">
<recvendorname> #trim(FORM.recVendorName)#</recvendorname>
<revdendorpoc>#trim(FORM.recVendorPOC)#</revdendorpoc>
<recvendoremail>#trim(FORM.recVendorEmail)#</recvendoremail>
<recvendorphone>#trim(FORM.recVendorPhone)#</recvendorphone>
<recvendoraddress>#trim(FORM.recVendorAddress)# #trim(FORM.recVendorAddressCity)#,#trim(FORM.recVendorAddressState)# #trim(FORM.recVendorAddressZipcode)#</recvendoraddress>
</cfif>
<cfif IsDefined ("Form.recVendorName2") AND Form.recVendorName2 NEQ "">
<recvendorname2> #trim(FORM.recVendorName2)#</recvendorname2>
<revdendorpoc2>#trim(FORM.recVendorPOC2)#</revdendorpoc2>
<recvendoremail2>#trim(FORM.recVendorEmail2)#</recvendoremail2>
<recvendorphone2>#trim(FORM.recVendorPhone2)#</recvendorphone2>
<recvendoraddress2>#trim(FORM.recVendorAddress2)# #trim(FORM.recVendorAddressCity2)#,#trim(FORM.recVendorAddressState2)# #trim(FORM.recVendorAddressZipcode2)#</recvendoraddress2>
</cfif>
<cfif IsDefined ("Form.recVendorName3") AND Form.recVendorName3 NEQ "">
<recvendorname3> #trim(FORM.recVendorName3)#</recvendorname3>
<revdendorpoc3>#trim(FORM.recVendorPOC3)#</revdendorpoc3>
<recvendoremail3>#trim(FORM.recVendorEmail3)#</recvendoremail3>
<recvendorphone3>#trim(FORM.recVendorPhone3)#</recvendorphone3>
<recvendoraddress3>#trim(FORM.recVendorAddress3)# #trim(FORM.recVendorAddressCity3)#,#trim(FORM.recVendorAddressState3)# #trim(FORM.recVendorAddressZipcode3)#</recvendoraddress3>
</cfif>
</recommendedvendor>

Open in new window

Avatar of rrattie

ASKER

Can't believe I missed that!  : )

You rock!
good job, Tomarse111 - i have just tested it too and you are right - the missing # is the problem! points well earned.

Azadi