added i18N handling to all ParserBase

FIXED "'" escaping in properties
This commit is contained in:
patrick-werner 2020-03-10 14:19:19 +01:00
parent 584c5b5a27
commit c8187bc8f2
3 changed files with 34 additions and 24 deletions

View File

@ -35,6 +35,7 @@ import org.hl7.fhir.r5.formats.IParser.OutputStyle;
import org.hl7.fhir.r5.model.StructureDefinition;
import org.hl7.fhir.r5.model.StructureDefinition.TypeDerivationRule;
import org.hl7.fhir.r5.utils.ToolingExtensions;
import org.hl7.fhir.utilities.I18nConstants;
import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.utilities.validation.ValidationMessage;
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
@ -91,11 +92,11 @@ public abstract class ParserBase {
protected StructureDefinition getDefinition(int line, int col, String ns, String name) throws FHIRFormatError {
if (ns == null) {
logError(line, col, name, IssueType.STRUCTURE, "This '"+name+"' cannot be parsed as a FHIR object (no namespace)", IssueSeverity.FATAL);
logError(line, col, name, IssueType.STRUCTURE, context.formatMessage(I18nConstants.THIS__CANNOT_BE_PARSED_AS_A_FHIR_OBJECT_NO_NAMESPACE, name), IssueSeverity.FATAL);
return null;
}
if (name == null) {
logError(line, col, name, IssueType.STRUCTURE, "This cannot be parsed as a FHIR object (no name)", IssueSeverity.FATAL);
logError(line, col, name, IssueType.STRUCTURE, context.formatMessage(I18nConstants.THIS_CANNOT_BE_PARSED_AS_A_FHIR_OBJECT_NO_NAME), IssueSeverity.FATAL);
return null;
}
for (StructureDefinition sd : context.allStructures()) {
@ -107,13 +108,13 @@ public abstract class ParserBase {
return sd;
}
}
logError(line, col, name, IssueType.STRUCTURE, "This does not appear to be a FHIR resource (unknown namespace/name '"+ns+"::"+name+"')", IssueSeverity.FATAL);
logError(line, col, name, IssueType.STRUCTURE, context.formatMessage(I18nConstants.THIS_DOES_NOT_APPEAR_TO_BE_A_FHIR_RESOURCE_UNKNOWN_NAMESPACENAME_, ns, name), IssueSeverity.FATAL);
return null;
}
protected StructureDefinition getDefinition(int line, int col, String name) throws FHIRFormatError {
if (name == null) {
logError(line, col, name, IssueType.STRUCTURE, "This cannot be parsed as a FHIR object (no name)", IssueSeverity.FATAL);
logError(line, col, name, IssueType.STRUCTURE, context.formatMessage(I18nConstants.THIS_CANNOT_BE_PARSED_AS_A_FHIR_OBJECT_NO_NAME), IssueSeverity.FATAL);
return null;
}
// first pass: only look at base definitions
@ -129,7 +130,7 @@ public abstract class ParserBase {
return sd;
}
}
logError(line, col, name, IssueType.STRUCTURE, "This does not appear to be a FHIR resource (unknown name '"+name+"')", IssueSeverity.FATAL);
logError(line, col, name, IssueType.STRUCTURE, context.formatMessage(I18nConstants.THIS_DOES_NOT_APPEAR_TO_BE_A_FHIR_RESOURCE_UNKNOWN_NAME_, name), IssueSeverity.FATAL);
return null;
}

View File

@ -348,4 +348,9 @@ public class I18nConstants {
public final static String PROFILE__DOES_NOT_MATCH_FOR__BECAUSE_OF_THE_FOLLOWING_PROFILE_ISSUES__ = "Profile__does_not_match_for__because_of_the_following_profile_issues__";
public final static String THIS_ELEMENT_DOES_NOT_MATCH_ANY_KNOWN_SLICE_ = "This_element_does_not_match_any_known_slice_";
public final static String DEFINED_IN_THE_PROFILE = "defined_in_the_profile";
public final static String THIS_DOES_NOT_APPEAR_TO_BE_A_FHIR_RESOURCE_UNKNOWN_NAME_ = "This_does_not_appear_to_be_a_FHIR_resource_unknown_name_";
public final static String THIS_CANNOT_BE_PARSED_AS_A_FHIR_OBJECT_NO_NAME = "This_cannot_be_parsed_as_a_FHIR_object_no_name";
public final static String THIS_DOES_NOT_APPEAR_TO_BE_A_FHIR_RESOURCE_UNKNOWN_NAMESPACENAME_ = "This_does_not_appear_to_be_a_FHIR_resource_unknown_namespacename_";
public final static String THIS__CANNOT_BE_PARSED_AS_A_FHIR_OBJECT_NO_NAMESPACE = "This__cannot_be_parsed_as_a_FHIR_object_no_namespace";
}

View File

@ -266,14 +266,14 @@ Not_done_yet_ValidatorHostServicesexecuteFunction = Not done yet (ValidatorHostS
Not_done_yet_ValidatorHostServicescheckFunction = Not done yet (ValidatorHostServices.checkFunction)
Not_done_yet_ValidatorHostServicesresolveFunction_ = Not done yet (ValidatorHostServices.resolveFunction): {0}
Unable_to_find_base_definition_for_logical_model__from_ = Unable to find base definition for logical model: {0} from {1}
Same_id_on_multiple_elements__in_ = Same id '{0}'on multiple elements {1}/{2} in {3}
Same_id_on_multiple_elements__in_ = Same id ''{0}''on multiple elements {1}/{2} in {3}
No_path_on_element_Definition__in_ = No path on element Definition {0} in {1}
needs_a_snapshot = needs a snapshot
not_the_right_kind_of_structure_to_generate_schematrons_for = not the right kind of structure to generate schematrons for
Not_handled_yet_sortElements_ = Not handled yet (sortElements: {0}:{1})
Unable_to_resolve_profile__in_element_ = Unable to resolve profile {0} in element {1}
Cant_have_children_on_an_element_with_a_polymorphic_type__you_must_slice_and_constrain_the_types_first_sortElements_ = Can't have children on an element with a polymorphic type - you must slice and constrain the types first (sortElements: {0}:{1})
Unable_to_find_profile__at_ = Unable to find profile '{0}' at {1}
Cant_have_children_on_an_element_with_a_polymorphic_type__you_must_slice_and_constrain_the_types_first_sortElements_ = Can''t have children on an element with a polymorphic type - you must slice and constrain the types first (sortElements: {0}:{1})
Unable_to_find_profile__at_ = Unable to find profile ''{0}'' at {1}
Unhandled_situation_resource_is_profiled_to_more_than_one_option__cannot_sort_profile = Unhandled situation: resource is profiled to more than one option - cannot sort profile
Internal_recursion_detection_find_loop_path_recursion____check_paths_are_valid_for_path_ = Internal recursion detection: find() loop path recursion > {0} - check paths are valid (for path {1}/{2})
Internal_error___type_not_known_ = Internal error - type not known {0}
@ -284,28 +284,28 @@ Error_at__The_target_profile__is_not__valid_constraint_on_the_base_ = Error at {
Error_in_profile__at__Base_isSummary___derived_isSummary__ = Error in profile {0} at {1}: Base isSummary = {2}, derived isSummary = {3}
StructureDefinition__at__illegal_attempt_to_change_a_binding_from__to_ = StructureDefinition {0} at {1}: illegal attempt to change a binding from {2} to {3}
Unexpected_condition_in_differential_typeslicetypelistsize__1_at_ = Unexpected condition in differential: type-slice.type-list.size() != 1 at {0}/{1}
Unexpected_condition_in_differential_typeslicetypelistsize__10_and_implicit_slice_name_does_not_contain_a_valid_type__at_ = Unexpected condition in differential: type-slice.type-list.size() == 10 and implicit slice name does not contain a valid type ('{0}'?) at {1}/{2}
Attempt_to_use_a_snapshot_on_profile__as__before_it_is_generated = Attempt to use a snapshot on profile '{0}' as {1} before it is generated
Unexpected_condition_in_differential_typeslicetypelistsize__10_and_implicit_slice_name_does_not_contain_a_valid_type__at_ = Unexpected condition in differential: type-slice.type-list.size() == 10 and implicit slice name does not contain a valid type (''{0}''?) at {1}/{2}
Attempt_to_use_a_snapshot_on_profile__as__before_it_is_generated = Attempt to use a snapshot on profile ''{0}'' as {1} before it is generated
null_min = null min
_has_children__for_type__in_profile__but_cant_find_type = {0} has children ({1}) for type {2} in profile {3}, but can't find type
_has_children__for_type__in_profile__but_cant_find_type = {0} has children ({1}) for type {2} in profile {3}, but can''t find type
_has_children__and_multiple_types__in_profile_ = {0} has children ({1}) and multiple types ({2}) in profile {3}
Adding_wrong_path = Adding wrong path
Named_items_are_out_of_order_in_the_slice = Named items are out of order in the slice
The_base_snapshot_marks_a_slicing_as_closed_but_the_differential_tries_to_extend_it_in__at__ = The base snapshot marks a slicing as closed, but the differential tries to extend it in {0} at {1} ({2})
Not_done_yet = Not done yet
Unknown_type__at_ = Unknown type {0} at {1}
Differential_walks_into____but_the_base_does_not_and_there_is_not_a_single_fixed_type_The_type_is__This_is_not_handled_yet = Differential walks into '{0} (@ {1})', but the base does not, and there is not a single fixed type. The type is {2}. This is not handled yet
Differential_walks_into____but_the_base_does_not_and_there_is_not_a_single_fixed_type_The_type_is__This_is_not_handled_yet = Differential walks into ''{0} (@ {1})'', but the base does not, and there is not a single fixed type. The type is {2}. This is not handled yet
Slicing_rules_on_differential__do_not_match_those_on_base___rule___ = Slicing rules on differential ({0}) do not match those on base ({1}) - rule @ {2} ({3})
Slicing_rules_on_differential__do_not_match_those_on_base___disciminator___ = Slicing rules on differential ({0}) do not match those on base ({1}) - disciminator @ {2} ({3})
Slicing_rules_on_differential__do_not_match_those_on_base___order___ = Slicing rules on differential ({0}) do not match those on base ({1}) - order @ {2} ({3})
not_done_yet__slicing__types__ = not done yet - slicing / types @ {0}
Invalid_slicing__there_is_more_than_one_type_slice_at__but_one_of_them__has_min__1_so_the_other_slices_cannot_exist = Invalid slicing : there is more than one type slice at {0}, but one of them ({1}) has min = 1, so the other slices cannot exist
Did_not_find_type_root_ = Did not find type root: {0}
Error_at_path__Slice_for_type__has_wrong_type_ = Error at path {0}: Slice for type '{1}' has wrong type '{2}'
Error_at_path__Slice_for_type__has_wrong_type_ = Error at path {0}: Slice for type ''{1}'' has wrong type ''{2}''
Error_at_path__Slice_for_type__has_more_than_one_type_ = Error at path {0}: Slice for type '{1}' has more than one type '{2}'
Error_at_path__Slice_name_must_be__but_is_ = Error at path {0}: Slice name must be '{1}' but is '{2}'
Error_at_path__in__Type_slicing_with_slicingdiscriminatorpath__this = Error at path {0} in {1}: Type slicing with slicing.discriminator.path != '$this'
Error_at_path__in__Type_slicing_with_slicingdiscriminatortype__type = Error at path {0} in {1}: Type slicing with slicing.discriminator.type != 'type'
Error_at_path__Slice_name_must_be__but_is_ = Error at path {0}: Slice name must be ''{1}'' but is ''{2}''
Error_at_path__in__Type_slicing_with_slicingdiscriminatorpath__this = Error at path {0} in {1}: Type slicing with slicing.discriminator.path != ''$this''
Error_at_path__in__Type_slicing_with_slicingdiscriminatortype__type = Error at path {0} in {1}: Type slicing with slicing.discriminator.type != ''type''
Error_at_path__in__Type_slicing_with_slicingdiscriminatorcount__1 = Error at path {0} in {1}: Type slicing with slicing.discriminator.count() > 1
Error_at_path__in__Type_slicing_with_slicingordered__true = Error at path {0} in {1}: Type slicing with slicing.ordered = true
Adding_wrong_path_in_profile___vs_ = Adding wrong path in profile {0}: {1} vs {2}
@ -318,12 +318,12 @@ Unable_to_resolve_reference_to_ = Unable to resolve reference to {0}
Unable_to_find_element__in_ = Unable to find element {0} in {1}
Unable_to_find_base__for_ = Unable to find base {0} for {1}
Adding_wrong_path__outcomegetPath___resultPathBase__ = Adding wrong path - outcome.getPath() = {0}, resultPathBase = {1}
Illegal_path__in_differential_in__illegal_characters_ = Illegal path '{0}' in differential in {1}: illegal characters []
Illegal_path__in_differential_in__illegal_character_ = Illegal path '{0}' in differential in {1}: illegal character '{2}'
Illegal_path__in_differential_in__no_unicode_whitespace = Illegal path '{0}' in differential in {1}: no unicode whitespace
Illegal_path__in_differential_in__name_portion_exceeds_64_chars_in_length = Illegal path '{0}' in differential in {1}: name portion exceeds 64 chars in length
Illegal_path__in_differential_in__name_portion_mising_ = Illegal path '{0}' in differential in {1}: name portion mising ('..')
Illegal_path__in_differential_in__must_start_with_ = Illegal path '{0}' in differential in {1}: must start with {2}.{3}
Illegal_path__in_differential_in__illegal_characters_ = Illegal path ''{0}'' in differential in {1}: illegal characters []
Illegal_path__in_differential_in__illegal_character_ = Illegal path ''{0}'' in differential in {1}: illegal character ''{2}''
Illegal_path__in_differential_in__no_unicode_whitespace = Illegal path ''{0}'' in differential in {1}: no unicode whitespace
Illegal_path__in_differential_in__name_portion_exceeds_64_chars_in_length = Illegal path ''{0}'' in differential in {1}: name portion exceeds 64 chars in length
Illegal_path__in_differential_in__name_portion_mising_ = Illegal path ''{0}'' in differential in {1}: name portion missing (''..'')
Illegal_path__in_differential_in__must_start_with_ = Illegal path ''{0}'' in differential in {1}: must start with {2}.{3}
No_path_value_on_element_in_differential_in_ = No path value on element in differential in {0}
No_path_on_element_in_differential_in_ = No path on element in differential in {0}
Unxpected_internal_condition__no_source_on_diff_element = Unxpected internal condition - no source on diff element
@ -331,7 +331,7 @@ type_on_first_snapshot_element_for__in__from_ = type on first snapshot element f
type_on_first_differential_element = type on first differential element!
Circular_snapshot_references_detected_cannot_generate_snapshot_stack__ = Circular snapshot references detected; cannot generate snapshot (stack = {0})
Base__Derived_profiles_have_different_types____vs___ = Base & Derived profiles have different types ({0} = {1} vs {2} = {3})
Derived_profile__has_no_derivation_value_and_so_cant_be_processed = Derived profile {0} has no derivation value and so can't be processed
Derived_profile__has_no_derivation_value_and_so_cant_be_processed = Derived profile {0} has no derivation value and so can''t be processed
Derived_profile__has_no_type = Derived profile {0} has no type
Base_profile__has_no_type = Base profile {0} has no type
no_derived_structure_provided = no derived structure provided
@ -344,4 +344,8 @@ Details_for__matching_against_Profile_ = Details for {0} matching against Profil
Does_not_match_slice_ = Does not match slice "{0}"
Profile__does_not_match_for__because_of_the_following_profile_issues__ = Profile {0} does not match for {1} because of the following profile issues: {2}
This_element_does_not_match_any_known_slice_ = This element does not match any known slice{0}
defined_in_the_profile = defined in the profile
defined_in_the_profile = defined in the profile
This_does_not_appear_to_be_a_FHIR_resource_unknown_name_ = This does not appear to be a FHIR resource (unknown name "{0}")
This_cannot_be_parsed_as_a_FHIR_object_no_name = This cannot be parsed as a FHIR object (no name)
This_does_not_appear_to_be_a_FHIR_resource_unknown_namespacename_ = This does not appear to be a FHIR resource (unknown namespace/name "{0}::{1}")
This__cannot_be_parsed_as_a_FHIR_object_no_namespace = This "{0}2 cannot be parsed as a FHIR object (no namespace)