Project

Profile

Help

Feature #4671

closed

XdmValue.makeValue(Object) should use the standard Java-to-XDM conversion rules

Added by Michael Kay almost 4 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Low
Assignee:
Category:
-
Sprint/Milestone:
-
Start date:
2020-08-05
Due date:
% Done:

0%

Estimated time:
Legacy ID:
Applies to branch:
Fix Committed on Branch:
Fixed in Maintenance Release:
Platforms:

Description

The s9api method XdmValue.makeValue(Object) doesn't make use of the standard conversion rules in JPConverter (it has a more restricted set of conversion rules).

There are other places where the standard conversion rules seem to be unnecessarily augmented or adapted:

  • AbstractTransformerImpl.setParameter() does:
            if (value instanceof Sequence) {
                converted = (Sequence)value;
            } else if (value instanceof String) {
                converted = new UntypedAtomicValue(StringView.of((String) value));
            } else if (required.getPrimaryType() instanceof JavaExternalObjectType) {
                converted = new ObjectValue<>(value);
            } else {
                JPConverter converter = JPConverter.allocate(value.getClass(), null, config);
               
  • XPathExpressionImpl.evaluate() does
if (node instanceof ZeroOrOne) {
            node = ((ZeroOrOne) node).head();
        }
        if (node instanceof TreeInfo) {
            node = ((TreeInfo)node).getRootNode();
        }
        if (node instanceof NodeInfo) {
            if (!((NodeInfo) node).getConfiguration().isCompatible(config)) {
                throw new XPathExpressionException(
                        "Supplied node must be built using the same or a compatible Configuration");
            }
            if (node instanceof TreeInfo && ((TreeInfo) node).isTyped() && !executable.isSchemaAware()) {
                throw new XPathExpressionException(
                        "The expression was compiled to handled untyped data, but the input is typed");
            }
            contextItem = (NodeInfo) node;
        } else if (node instanceof Item) {
            contextItem = (Item) node;
        } else {
            JPConverter converter = JPConverter.allocate(node.getClass(), null, config);
            

Please register to edit this issue

Also available in: Atom PDF