001/* 002 * SPDX-FileCopyrightText: none 003 * SPDX-License-Identifier: CC0-1.0 004 */ 005 006package dev.metaschema.core.metapath; 007 008import dev.metaschema.core.configuration.AbstractConfigurationFeature; 009import edu.umd.cs.findbugs.annotations.NonNull; 010 011/** 012 * Provides a mechanism to configure Metapath evaluation settings. 013 * 014 * @param <V> 015 * the feature value Java type 016 */ 017public final class MetapathEvaluationFeature<V> 018 extends AbstractConfigurationFeature<V> { 019 /** 020 * If enabled, evaluate <a href= 021 * "https://www.w3.org/TR/xpath-31/#id-filter-expression">predicates</a>, 022 * otherwise skip evaluating them. 023 */ 024 @NonNull 025 public static final MetapathEvaluationFeature<Boolean> METAPATH_EVALUATE_PREDICATES 026 = new MetapathEvaluationFeature<>("evaluate-predicates", Boolean.class, true); 027 028 /** 029 * If enabled, atomization of a node item that has no associated typed value 030 * (for example, a flag or field node reached while walking a module definition 031 * rather than an instance document) yields a {@code null} atomic value instead 032 * of raising 033 * {@link dev.metaschema.core.metapath.function.InvalidTypeFunctionException} 034 * with code 035 * {@link dev.metaschema.core.metapath.function.InvalidTypeFunctionException#NODE_HAS_NO_TYPED_VALUE}. 036 * <p> 037 * This is intended for visitors and tools that traverse an 038 * {@link dev.metaschema.core.metapath.item.node.IModuleNodeItem} graph and need 039 * downstream function calls (for example {@code fn:resolve-uri} or 040 * {@code fn:doc}) to degrade gracefully when they receive a no-data flag rather 041 * than an instance value. 042 */ 043 @NonNull 044 public static final MetapathEvaluationFeature<Boolean> METAPATH_ATOMIZE_NO_DATA_AS_EMPTY 045 = new MetapathEvaluationFeature<>("atomize-no-data-as-empty", Boolean.class, false); 046 047 private MetapathEvaluationFeature( 048 @NonNull String name, 049 @NonNull Class<V> valueClass, 050 @NonNull V defaultValue) { 051 super(name, valueClass, defaultValue); 052 } 053}