This email refers to this issue:
http://code.google.com/p/openbluedragon/issues/detail?id=44

Thanks for fixing this issue, however it appears there is an additional 
issue going on.

I'm using this code below.  ComparisionA and ComparisonB return true.  
The array in ComparisonC has the same data as ComparisionA and 
ComparisonB.  The problem is ComparisonA.equals(ComparisonC) returns 
false even thought the array is the same.

<cffunction name="recurseComplexValues" access="public" returntype="any" 
output="false"
    hint="Recurses through complex values by type.">
    <cfargument name="node" type="any" required="true" />
    
    <cfset var value = "" />
    <cfset var child = "" />
    <cfset var i = "" />
    
    <cfif StructKeyExists(arguments.node.xmlAttributes, "value")>
        <cfset value = arguments.node.xmlAttributes["value"] />
    <cfelseif ArrayLen(arguments.node.xmlChildren)>
        <cfset child = arguments.node.xmlChildren[1] />
        <cfif child.xmlName EQ "value">
            <cfset value = child.xmlText />
        <cfelseif child.xmlName EQ "struct">
            <cfset value = StructNew() />
            <cfloop from="1" to="#ArrayLen(child.xmlChildren)#" index="i">
                <cfset value[child.xmlChildren[i].xmlAttributes["name"]] 
= recurseComplexValues(child.xmlChildren[i]) />
            </cfloop>
        <cfelseif child.xmlName EQ "array">
            <cfset value = ArrayNew(1) />
            <cfloop from="1" to="#ArrayLen(child.xmlChildren)#" 
index="i">            
                <cfset ArrayAppend(value, 
recurseComplexValues(child.xmlChildren[i])) />
            </cfloop>
        </cfif>
    </cfif>
    
    <cfreturn value />
</cffunction>

<cfset variables.parsedXml = XmlParse('<root><array name="test"><element 
value="1"/><element><value>2</value></element></array></root>') />

<cfset comparisonA = ArrayNew(1) />
<cfset comparisonB = ArrayNew(1) />
<cfset comparisonC = recurseComplexValues(variables.parsedXml.root) />

<cfset comparisonA[1] = 1 />
<cfset comparisonA[2] = 2 />

<cfset comparisonB[1] = 1 />
<cfset comparisonB[2] = 2 />

<cfdump var="#comparisonA#">
<cfdump var="#comparisonB#">
<cfdump var="#comparisonC#">
A to B: <cfdump var="#comparisonA.equals(comparisonB)#"><br/>
A to C:<cfdump var="#comparisonA.equals(comparisonC)#">

RESULTS
A to B: true
A to C: false

I think I've narrowed down the issue.  If I change ComparisonA to this 
(notice the quotes around the values):

<cfset comparisonA[1] = "1" />
<cfset comparisonA[2] = "2" />

The results change to this:
A to B: false
A to C: true

Clearly this has to do with "1" being like a "string" and when it's just 
1 then it's just a "numeric".  Essentially they should be the both 
return true when a comparison is being done?

Best,
.Peter

P.s.  I've also tried this with structs (which is Issue 43) using the 
same function (which I won't paste in again) and the same equals stuff 
does not work:

<cfset variables.parsedXml = XmlParse('<root><struct name="test"><key 
name="a" value="1"/><key 
name="b"><value>2</value></key></struct></root>') />

<cfset comparisonA = StructNew() />
<cfset comparisonB = StructNew(1) />
<cfset comparisonC = recurseComplexValues(variables.parsedXml.root) />

<cfset comparisonA.a = "1" />
<cfset comparisonA.b = "2" />

<cfset comparisonB.a = 1 />
<cfset comparisonB.b = 2 />

A to B: <cfdump var="#comparisonA.equals(comparisonB)#"><br/>
A to C: <cfdump var="#comparisonA.equals(comparisonC)#">


--~--~---------~--~----~------------~-------~--~----~
Open BlueDragon Public Mailing List
 http://groups.google.com/group/openbd?hl=en
 official site @ http://www.openbluedragon.org/

!! save a network - trim replies before posting !!
-~----------~----~----~----~------~----~------~--~---

Reply via email to