class Lutaml::Xml::Schema::Xsd::Errors::Troubleshooters::NamespaceTroubleshooter
error.troubleshooting_tips # => [“Check if namespace prefix…”, …]
)
}
actual_value: “gml:CodeType”
namespace: “www.opengis.net/gml/3.2”,
context: {
“Namespace prefix ‘gml’ not found”,
error = NamespaceError.new(
end
use_troubleshooter NamespaceTroubleshooter
class NamespaceError < EnhancedError
@example Using the troubleshooter
Provides tips for resolving namespace issues
Troubleshooter for namespace-related errors
def extract_prefix(qualified_name)
-
(String)- The prefix (e.g., "gml")
Parameters:
-
qualified_name(String) -- The qualified name (e.g., "gml:CodeType")
def extract_prefix(qualified_name) qualified_name.to_s.split(":").first end
def general_namespace_tips
-
(Array- Tips)
def general_namespace_tips [ "List available namespaces: lutaml-xsd namespace list --from package.lxr", "Check namespace configuration in config/namespace_mapping.yml", "Ensure all required schemas are imported", ] end
def namespace_prefix_tips(context)
-
(Array- Tips)
Parameters:
-
context(ErrorContext) -- Error context
def namespace_prefix_tips(context) prefix = extract_prefix(context.actual_value) [ "Check if namespace prefix '#{prefix}' is registered", "Verify the prefix mapping in your schema configuration", ] end
def namespace_uri_tips(context)
-
(Array- Tips)
Parameters:
-
context(ErrorContext) -- Error context
def namespace_uri_tips(context) [ "Verify namespace URI is correct: #{context.namespace}", "Check if the namespace is registered in your schema package", ] end
def tips_for(error)
-
(Array- Troubleshooting tips)
Parameters:
-
error(EnhancedError) -- The error
def tips_for(error) return [] unless can_troubleshoot?(error) tips = [] context = context_from(error) tips.concat(namespace_uri_tips(context)) if context.namespace tips.concat(namespace_prefix_tips(context)) if context.actual_value&.include?(":") tips.concat(general_namespace_tips) tips end