BoxLang: Our new JVM Dynamic Language made by Ortus! Check it out: https://www.boxlang.io

Error Getting method keyExists for class ortus.boxlang.runtime.types.XML

Description

The following code:

xmlText = "<Ortus><Products><Product>BoxLang</Product><Product>CommandBox</Product><Product>Coldbox</Product></Products></Ortus>"; parsed = xmlParse( xmlText ); writeDump( parsed.xmlRoot.xmlChildren.filter( (child ) => child.keyExists( "Product" ) ) );

Produces the exception:

ortus.boxlang.runtime.types.exceptions.BoxRuntimeException: Error getting method keyExists for class ortus.boxlang.runtime.types.XML at ortus.boxlang.runtime.interop.DynamicInteropService.invoke(DynamicInteropService.java:508) at ortus.boxlang.runtime.interop.DynamicInteropService.invoke(DynamicInteropService.java:454) at ortus.boxlang.runtime.interop.DynamicInteropService.invoke(DynamicInteropService.java:435) at ortus.boxlang.runtime.types.XML.dereferenceAndInvoke(XML.java:564) at ortus.boxlang.runtime.interop.DynamicInteropService.dereferenceAndInvoke(DynamicInteropService.java:1880) at ortus.boxlang.runtime.interop.DynamicInteropService.dereferenceAndInvoke(DynamicInteropService.java:1854) at ortus.boxlang.runtime.dynamic.Referencer.getAndInvoke(Referencer.java:89)

structKeyExists does, however, work.


.keyExists should be present as a member function for XML objects and should return true for child nodes

Activity

Show:

Jon Clausen January 18, 2025 at 7:26 PM

I was able to resolve this with the explicit member name:

@BoxMember( type = BoxLangType.XML, name = "keyExists" )

Jon Clausen January 18, 2025 at 7:13 PM

I see that XML implements IStruct but, even when I put @BoxMember( type = BoxLangType.XML ) on the StructKeyExists BIF, it still fails with the same error. Re-assigning this one to

Fixed
Pinned fields
Click on the next to a field label to start pinning.

Details

Assignee

Reporter

Fix versions

Priority

Sentry

Created January 18, 2025 at 6:46 PM
Updated January 18, 2025 at 7:26 PM
Resolved January 18, 2025 at 7:25 PM

Flag notifications