tracker issue : CF-4203285

select a category, or use search below
(searches all categories and all time range)
Title:

[ANeff] ER for: relevant string, struct and array member functions on XML variables (Part 2)

| View in Tracker

Status/Resolution/Reason: To Fix//BugVerified

Reporter/Name(from Bugbase): Aaron Neff / ()

Created: 08/20/2018

Components: Language, Member Functions

Versions: 2018

Failure Type: Enhancement Request

Found In Build/Fixed In Build: latest build /

Priority/Frequency: Normal /

Locale/System: / Platforms All

Vote Count: 1

ER for: relevant string, struct and array member functions on XML variables (Part 2)

1) In CF-4199973, I mistakenly excluded XML member functions .clear(), .delete() and .deleteAt()
2) In CF-4199973, Adobe added .hasChild(), instead of .isEmpty(), for ArrayIsEmpty()'s and StructIsEmpty()'s functionality. However, there are 2 issues w/ .hasChild():
2a) .hasChild() always returns YES, even when a node has zero children
2b) .hasChild() only covers StructIsEmpty()'s functionality, so it needs an optional 'childName' parameter in order to cover ArrayIsEmpty()'s functionality.

Note: 'childName' was chosen for consistency w/ XmlElemNew()'s and XmlChildPos()'s 'childName' parameter.

See blog: http://blog.cfaether.com/2018/08/coldfusion-member-functions-for-xml.html

-----------
Observation 1:
.clear() would seemingly be ambiguous, since ArrayClear() and StructClear() can both be used on an XML object. However, ArrayClear(xml) actually *deletes* nodes and its functionality is already covered by StructDelete() and ArrayDeleteAt(). ArrayClear(xmlFoo.xmlBar) deletes all nodes named 'xmlBar' under xmlFoo (equivalent of StructDelete(xmlFoo, "xmlBar")). ArrayClear(xmlFoo.xmlBar[2]) deletes the second node named 'xmlBar' under xmlFoo (equivalent of ArrayDeleteAt(xmlFoo.xmlBar, 2)). So, xmlObject.clear()/XMLClear(xmlObject) should be added to cover StructClear(xmlObject)'s functionality. StructClear(xmlFoo.xmlBar) and StructClear(xmlFoo.xmlBar[1]) clear (convert to empty node) the first node named 'xmlBar' under xmlFoo. ArrayClear() Repro: https://trycf.com/gist/49487fe7e971236bafe0a6685374ca86/acf2018?theme=monokai. StructClear() Repro: https://trycf.com/gist/e04db3702a5bdbbe06de6896639452c5/acf2018?theme=monokai.

Observation 2:
No equivalent for StructDelete() was added. StructDelete(xmlFoo, "xmlBar") deletes all nodes named 'xmlBar' under xmlFoo. So, xmlObject.delete(childName)/XMLDelete(xmlObject, childName) should be added to cover StructDelete(xmlObject, childName)'s functionality. Repro: https://trycf.com/gist/493f0ae6ba00a7d2b528394fa36a1898/acf2018?theme=monokai.

Observation 3:
No equivalent for ArrayDeleteAt() was added. ArrayDeleteAt(xmlFoo.xmlBar, 2) deletes the second node named 'xmlBar' under xmlFoo. So, xmlObject.deleteAt(position)/XMLDeleteAt(xmlObject, position) should be added to cover ArrayDeleteAt(xmlObject, position)'s functionality. Repro: https://trycf.com/gist/1aa6b58603f20739907bfa21ff540ff5/acf2018?theme=monokai.

Observation 6:
.hasChild() currently doesn't work (always returns YES) and, if it did, only covers StructIsEmpty()'s functionality but not ArrayIsEmpty's. So, xmlObject.hasChild([childName])/XMLHasChild(xmlObject[, childName]) needs an optional 'childName' parameter, in order to also cover ArrayIsEmpty(xmlObject.childName)'s functionality. Repro: https://trycf.com/gist/0db692627ccefdfbe436e756988c10c1/acf2018?theme=monokai.
-----------
Observation 11:
Currently, xmlObject.update() returns a struct that doesn't contain, for example, the updated xmlText. So, xmlObject.update() needs fixed to return the updated XML. Repro: https://trycf.com/gist/4031ebc027c788574948183387b56b68/acf2018?theme=monokai

Attachments:

Comments:

Wish I could update the description. I forgot to add this: Observation 11: Currently, xmlObject.update() returns a struct that doesn't contain, for example, the updated xmlText. So, xmlObject.update() needs fixed to return the updated XML. Repro: https://trycf.com/gist/4031ebc027c788574948183387b56b68/acf2018?theme=monokai
Comment by Aaron N.
29551 | August 20, 2018 07:49:36 AM GMT