Skip to content

[java] Simplify xpath typeof syntax #1115

@oowekyala

Description

@oowekyala

The typeof function currently uses three arguments that appear to be quite redundant (and are not documented other than a single example). The documentation is outdated too, mentioning that only ClassOrInterfaceType is supported

What I gather is

  • First arg is always @Image -> this could be inferred from the context node, just like the metric function is called with simply metric('NCSS').
  • Second arg is FQCN of the type we want to match
  • Third arg is the simple name of the type -> redundant, could be inferred from the FQCN

I think we could create a new function (for compatibility), e.g. typeIs (this name seems clearer anyway since it returns a boolean), that you could call like:

//ClassOrInterfaceType[typeIs('java.lang.StringBuilder')]

Metadata

Metadata

Assignees

Labels

in:documentationAffects the documentation [doc]in:type-resolutionAffects the type resolution codein:xpathRelating to xpath support at large, eg Jaxen / Saxon, custom functions, attribute resolution

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions