Title:
[ANeff] ER for: relevant string, struct and array member functions on XML variables
| View in TrackerStatus/Resolution/Reason: Closed/Fixed/Fixed
Reporter/Name(from Bugbase): Aaron Neff / Aaron Neff ()
Created: 10/08/2017
Components: Language, Member Functions
Versions: 2016
Failure Type: Others
Found In Build/Fixed In Build: / 2018.0.0.308743
Priority/Frequency: Normal /
Locale/System: /
Vote Count: 1
This ER is for: relevant string, struct and array member functions on XML variables
The following String, Struct and Array functions can be used on XML variables, but their member function equivalents don't: toString(), arrayLen(), arrayIsEmpty(), structCount(), structIsEmpty(), structKeyList(), structKeyArray(), structAppend() and structUpdate().
The following member functions should be added to XML variables: .toString(), .len(), .count(), .isEmpty(), .keyList(), .keyArray(), .append(), .update()
Once this ER is implemented, the following should return the expected results notated in the comments:
<cfxml variable="myXMLVar">
<myXML a="b">
<foo>foo1</foo>
<foo>foo2</foo>
<foo></foo>
<bar>bar1</bar>
<bar></bar>
foobar
</myXML>
</cfxml>
<cfscript>
//xml.toString()
writeOutput(toString(myXMLVar) & '<br>');//foo1 foo2 bar1 foobar
writeOutput(myXMLVar.toString() & '<br>');//should return "foo1 foo2 bar1 foobar" but returns "[#document: null]"
//xmlElement.len()
writeOutput(arrayLen(myXMLVar.myXML.foo) & '<br>');//3
writeOutput(myXMLVar.myXML.foo.len() & '<br>');//should return "3" but throws "The len method was not found."
//xmlElement.isEmpty()
writeOutput(arrayIsEmpty(myXMLVar.myXML) & '<br>');//NO
writeOutput(myXMLVar.myXML.isEmpty() & '<br>');//should return "NO" but throws "The isEmpty method was not found."
//xmlElement.count()
writeOutput(structCount(myXMLVar.myXML) & '<br>');//5
writeOutput(myXMLVar.myXML.count() & '<br>');//should return "5" but throws "The count method was not found."
//xmlElement.isEmpty()
writeOutput(structIsEmpty(myXMLVar.myXML.foo[1]) & '<br>');//YES
writeOutput(myXMLVar.myXML.foo[1].isEmpty() & '<br>');//should return "YES" but throws "The isEmpty method was not found."
//xmlElement.keyList()
writeOutput(structKeyList(myXMLVar.myXML) & '<br>');//foo,foo,foo
writeOutput(myXMLVar.myXML.keyList() & '<br>');//should return "foo,foo,foo" but throws "The keyList method was not found."
//xmlElement.keyArray()
writeDump(structKeyArray(myXMLVar.myXML));//[foo,foo,foo]
writeDump(myXMLVar.myXML.keyArray());//should return [foo,foo,foo] but throws "The keyArray method was not found."
//xmlElement.append()
xmlElem = xmlElemNew(myXMLVar, "myXML");
xmlElem.xmlChildren[1] = xmlElemNew(myXMLVar, "newElement");
xmlElem.xmlChildren[1].xmlText = "new element value";
writeOutput(structAppend(myXMLVar.myXML.bar[1], xmlElem));//YES
writeDump(myXMLVar.myXML.bar[1].append(xmlElem));//should return updated XML element but throws "The append method was not found."
//xmlElement.update()
writeOutput(structUpdate(myXMLVar.myXML, "xmlText", "bla bla"));//YES
writeDump(myXMLVar.myXML.update("xmlText", "bla bla"));//should return updated XML element but throws "The update method was not found."
</cfscript>
Note: arrayIsEmpty(myXMLVar) and structIsEmpty(myXMLVar) both serve the same purpose (identifying if a node has any children) and thus there's no conflict and the member function can be .isEmpty()
Related URL: https://helpx.adobe.com/coldfusion/developing-applications/using-web-elements-and-external-objects/using-xml-and-wddx/modifying-a-coldfusion-xml-object.html
Attachments:
Comments: