Skip to main content
Inspiring
July 14, 2010
Answered

Custom Tag Errors - Complex Oblect Types

  • July 14, 2010
  • 1 reply
  • 878 views

I am at a loss here again...

But this is a little more complex as it is a custom tag - pulling some xml parsing...

And I get the error - works in CF5 though...

----------------------------------

Here is the code calling the custom tag...

<cfoutput>#term# - final Just before 7</cfoutput><br>

[the code prior to this is properly spitting out the "term" to the 7xml custom below]

<cf_7xmlparser mt="#URLEncodedFormat(term)#" ip="#REMOTE_ADDR#" mode="array"></cf_7xmlparser>

<!---test array output--->
<cfset x = 1>
<cfloop condition="x LTE arraylen(dataArry)">
    <table border=0 cellspacing=0 cellpadding=5>
<cfoutput>
<tr>
<td valign=top class=verd9>
<b><a href="#dataArry["URL"]#">#dataArry["name"]#</a></b>
<br><span class=verd7>#dataArry["description"]#</span>
</td></tr>
</cfoutput>
</table>
<cfset x = incrementvalue(x)>
</cfloop>

----------------------------------

This is the 7xml - "cf_7xmlparser" code - which was working fine in CF5 - not in CF8 though...

<cfsetting enablecfoutputonly="yes">

<!---make sure it only processes once--->

<cfif thisTag.executionMode EQ "start">

<!---default is array mode, mode also can be display--->
  <cfset mode = "array">

<cfif isdefined("attributes.mt")>
  <cfset mt = attributes.mt>
  <cfif len(trim(mt)) EQ 0>
   <cfoutput>
    <br><br>
    The value of the <b>mt</b> attribute is null, please check the custom tag call.
   </cfoutput>
   <cfexit>
  </cfif>
<cfelse>
  <cfoutput>
   <br><br>
   The <b>mt</b> attribute is a required attribute for this tag.
  </cfoutput>
  <cfexit>
</cfif>

<cfif isdefined("attributes.ip")>
  <cfset ip = attributes.ip>
  <cfif len(trim(ip)) EQ 0>
   <cfoutput>
    <br><br>
    The value of the <b>ip</b> attribute is null, please check the custom tag call.
   </cfoutput>
   <cfexit>
  </cfif>
<cfelse>
  <cfoutput>
   <br><br>
   The <b>ip</b> attribute is a required attribute for this tag.
  </cfoutput>
  <cfexit>
</cfif>


<!---build feed url--->
<cfset feedURL = "http://meta.7search.com/feed/xml.aspx?affiliate=63381&token=D963B03891934F789ABA8E0F3D66E4F6&pn=1&r=20&filter=no&st=typein&rid=medexplorer.com&qu=" & mt & "&ip_address=" & ip>

<!---retrive xml data--->
<cfhttp url="#feedURL#" method="get"></cfhttp>

<cfset feedData = cfhttp.filecontent>
 
<cfset findOne = '<site '>
<cfset findTwo = '</site>'>

<cfset posTest = findnocase(findOne, feedData)>
<cfset passcnt = 1>
<cfset recLen = 0>

<!---create array on calling page--->
<cfif mode EQ "array">
  <cfset caller.dataArry = arraynew(1)>
</cfif>

<cfloop condition="posTest NEQ 0">
 
  <!---create new structure for each pass--->
  <cfif mode EQ "array">
   <cfset dataStruct = structnew()>
  </cfif>
 
<cfset findOne = '<site '>
<cfset findTwo = '</site>'>

  <!---get start point--->
  <cfif passcnt NEQ 1>
   <cfset posTest = findnocase(findOne, feedData, posTestx)>
  </cfif>

  <cfif posTest EQ 0>
   <cfbreak>
  </cfif>
 
  <!---get record data--->
  <cf_parsetext vContent="#feedData#" posOne="#int(posTest + 7)#" findOne="#findOne#" findTwo="#findTwo#">

  <cfset recordData = mH>
  <cfset posTestx = posTwo + 7>
   
  <!-------------parse each element------------------>
 
     <!---get url--->
  <cfset findOne = "<url>">
  <cfset findTwo = "</url>">
  <cfset p1 = findnocase(findOne, recordData)>
  <cf_parsetext vContent="#recordData#" posOne="#int((p1 + len(findOne)) - 1)#" findOne="#findOne#" findTwo="#findTwo#"> 

  <cfset url = replacenocase(replacenocase(mh, "<![CDATA[", ""), "]]>", "")>
  <cfif mode EQ "array">
   <cfset rc = structinsert(dataStruct, "url", url)>
  </cfif>
 
     <!---get name--->
  <cfset findOne = "<name>">
  <cfset findTwo = "</name>">
  <cfset p1 = findnocase(findOne, recordData)>
  <cf_parsetext vContent="#recordData#" posOne="#int((p1 + len(findOne)) - 1)#" findOne="#findOne#" findTwo="#findTwo#"> 

  <cfset name = replacenocase(replacenocase(mh, "<![CDATA[", ""), "]]>", "")>
  <cfif mode EQ "array">
   <cfset rc = structinsert(dataStruct, "name", name)>
  </cfif>
 
     <!---get description--->
  <cfset findOne = "<description>">
  <cfset findTwo = "</description>">
  <cfset p1 = findnocase(findOne, recordData)>
  <cf_parsetext vContent="#recordData#" posOne="#int((p1 + len(findOne)) - 1)#" findOne="#findOne#" findTwo="#findTwo#"> 

  <cfset description = replacenocase(replacenocase(mh, "<![CDATA[", ""), "]]>", "")>
  <cfif mode EQ "array">
   <cfset rc = structinsert(dataStruct, "description", description)>
  </cfif>

  <!---save structure data to array and put into array of calling page--->
  <cfif mode EQ "array">
   <cfset caller.dataArry[passcnt] = dataStruct>
  </cfif>
 
  <cfset passcnt = incrementvalue(passcnt)>
</cfloop>

</cfif>

<cfsetting enablecfoutputonly="no">

----------------------------------

Below is the error code...

I'm lost...

----------------------------------

Line 108 below was the error line bolded...

Complex object types cannot be converted to simple values.

The expression has requested a variable or an intermediate expression result as a simple value, however, the result cannot be converted to a simple value. Simple values are strings, numbers, boolean values, and date/time values. Queries, arrays, and COM objects are examples of complex values.

The most likely cause of the error is that you are trying to use a complex value as a simple one. For example, you might be trying to use a query variable in a cfif tag.

The error occurred in C:\ColdFusion8\CustomTags\cfwcustom.cfm: line 108
Called from D:\medexplorer\cfinclude\_navigate.cfm: line 41
Called from D:\medexplorer\navigate.cfm: line 14
106 :      <tr>
107 :      <td valign=top class=verd9>
108 :      <b><a href="#dataArry["URL"]#">#dataArry["name"]#</a></b>
109 :      <br><span class=verd7>#dataArry["description"]#</span>
110 :      </td></tr>

    This topic has been closed for replies.
    Correct answer ilssac

    In CF5, URL was not a reservered word.

    From CF6 and on, it is now a reserved word for the URL scope, i.e the get headers from the request.

    If that is not the problem.  Dump the variable causing the problem

    <cfdump var="#aVar#">  And see what the structure looks like.

    1 reply

    ilssac
    ilssacCorrect answer
    Inspiring
    July 14, 2010

    In CF5, URL was not a reservered word.

    From CF6 and on, it is now a reserved word for the URL scope, i.e the get headers from the request.

    If that is not the problem.  Dump the variable causing the problem

    <cfdump var="#aVar#">  And see what the structure looks like.

    Inspiring
    July 14, 2010

    Thanx so much Ian...

    I figured it would be something simple like that...

    I have had similar issues with reserved words in access - but I didn't even think of that...

    I changed URL to SEVENURL - works fine...

    I'm back on my way to updating server... Thanx...