Skip to content

Commit 71473d2

Browse files
committed
Refactor XPath validation rules
1 parent 8ebd226 commit 71473d2

File tree

1 file changed

+67
-22
lines changed

1 file changed

+67
-22
lines changed

src/main/java/org/entur/netex/validation/validator/xpath/DefaultValidationTreeFactory.java

+67-22
Original file line numberDiff line numberDiff line change
@@ -742,42 +742,54 @@ protected ValidationTree getTimetableFrameValidationTree(String path) {
742742
new ValidateNotExist(
743743
"vehicleJourneys/ServiceJourney/passingTimes/TimetabledPassingTime[not(DepartureTime or EarliestDepartureTime) and not(ArrivalTime or LatestArrivalTime)]",
744744
"SERVICE_JOURNEY_4",
745-
"TimetabledPassingTime contains neither DepartureTime/EarliestDepartureTime nor ArrivalTime/LatestArrivalTime"
745+
"ServiceJourney missing arrival and departure",
746+
"TimetabledPassingTime contains neither DepartureTime/EarliestDepartureTime nor ArrivalTime/LatestArrivalTime",
747+
Severity.ERROR
746748
)
747749
);
748750
validationTree.addValidationRule(
749751
new ValidateNotExist(
750752
"vehicleJourneys/ServiceJourney[not(passingTimes/TimetabledPassingTime[1]/DepartureTime) and not(passingTimes/TimetabledPassingTime[1]/EarliestDepartureTime)]",
751753
"SERVICE_JOURNEY_5",
752-
"All TimetabledPassingTime except last call must have DepartureTime"
754+
"ServiceJourney missing departure times",
755+
"All TimetabledPassingTime except last call must have DepartureTime",
756+
Severity.ERROR
753757
)
754758
);
755759
validationTree.addValidationRule(
756760
new ValidateNotExist(
757761
"vehicleJourneys/ServiceJourney[count(passingTimes/TimetabledPassingTime[last()]/ArrivalTime) = 0 and count(passingTimes/TimetabledPassingTime[last()]/LatestArrivalTime) = 0]",
758762
"SERVICE_JOURNEY_6",
759-
"Last TimetabledPassingTime must have ArrivalTime"
763+
"ServiceJourney missing arrival time for last stop",
764+
"Last TimetabledPassingTime must have ArrivalTime",
765+
Severity.ERROR
760766
)
761767
);
762768
validationTree.addValidationRule(
763769
new ValidateNotExist(
764770
"vehicleJourneys/ServiceJourney/passingTimes/TimetabledPassingTime[DepartureTime = ArrivalTime]",
765771
"SERVICE_JOURNEY_7",
766-
"ArrivalTime is identical to DepartureTime"
772+
"ServiceJourney identical arrival and departure",
773+
"ArrivalTime is identical to DepartureTime",
774+
Severity.WARNING
767775
)
768776
);
769777
validationTree.addValidationRule(
770778
new ValidateNotExist(
771779
"vehicleJourneys/ServiceJourney/passingTimes/TimetabledPassingTime[not(@id)]",
772780
"SERVICE_JOURNEY_8",
773-
"Missing id on TimetabledPassingTime"
781+
"ServiceJourney missing id on TimetabledPassingTime",
782+
"Missing id on TimetabledPassingTime",
783+
Severity.WARNING
774784
)
775785
);
776786
validationTree.addValidationRule(
777787
new ValidateNotExist(
778788
"vehicleJourneys/ServiceJourney/passingTimes/TimetabledPassingTime[not(@version)]",
779789
"SERVICE_JOURNEY_9",
780-
"Missing version on TimetabledPassingTime"
790+
"ServiceJourney missing version on TimetabledPassingTime",
791+
"Missing version on TimetabledPassingTime",
792+
Severity.WARNING
781793
)
782794
);
783795

@@ -789,115 +801,147 @@ protected ValidationTree getTimetableFrameValidationTree(String path) {
789801
new ValidateNotExist(
790802
"vehicleJourneys/ServiceJourney[not(JourneyPatternRef)]",
791803
"SERVICE_JOURNEY_10",
792-
"The ServiceJourney does not refer to a JourneyPattern"
804+
"ServiceJourney missing reference to JourneyPattern",
805+
"The ServiceJourney does not refer to a JourneyPattern",
806+
Severity.ERROR
793807
)
794808
);
795809
validationTree.addValidationRule(
796810
new ValidateNotExist(
797811
"vehicleJourneys/ServiceJourney[(TransportMode and not(TransportSubmode)) or (not(TransportMode) and TransportSubmode)]",
798812
"SERVICE_JOURNEY_11",
799-
"If overriding Line TransportMode or TransportSubmode on a ServiceJourney, both elements must be present"
813+
"ServiceJourney invalid overriding of transport modes",
814+
"If overriding Line TransportMode or TransportSubmode on a ServiceJourney, both elements must be present",
815+
Severity.WARNING
800816
)
801817
);
802818
validationTree.addValidationRule(
803819
new ValidateNotExist(
804820
"vehicleJourneys/ServiceJourney[not(OperatorRef) and not(//ServiceFrame/lines/*[self::Line or self::FlexibleLine]/OperatorRef)]",
805821
"SERVICE_JOURNEY_12",
806-
"Missing OperatorRef on ServiceJourney (not defined on Line)"
822+
"ServiceJourney missing OperatorRef",
823+
"Missing OperatorRef on ServiceJourney (not defined on Line)",
824+
Severity.ERROR
807825
)
808826
);
809827
validationTree.addValidationRule(
810828
new ValidateNotExist(
811829
"vehicleJourneys/ServiceJourney[not(dayTypes/DayTypeRef) and not(@id=//TimetableFrame/vehicleJourneys/DatedServiceJourney/ServiceJourneyRef/@ref)]",
812830
"SERVICE_JOURNEY_13",
813-
"The ServiceJourney does not refer to DayTypes nor DatedServiceJourneys"
831+
"ServiceJourney missing reference to calendar data",
832+
"The ServiceJourney does not refer to DayTypes nor DatedServiceJourneys",
833+
Severity.ERROR
814834
)
815835
);
816836
validationTree.addValidationRule(
817837
new ValidateNotExist(
818838
"vehicleJourneys/ServiceJourney[dayTypes/DayTypeRef and @id=//TimetableFrame/vehicleJourneys/DatedServiceJourney/ServiceJourneyRef/@ref]",
819839
"SERVICE_JOURNEY_14",
820-
"The ServiceJourney references both DayTypes and DatedServiceJourneys"
840+
"ServiceJourney duplicated reference to calendar data",
841+
"The ServiceJourney references both DayTypes and DatedServiceJourneys",
842+
Severity.ERROR
821843
)
822844
);
823845
validationTree.addValidationRule(
824846
new ValidateNotExist(
825847
"for $a in vehicleJourneys/ServiceJourney return if(count(//ServiceFrame/journeyPatterns/*[@id = $a/JourneyPatternRef/@ref]/pointsInSequence/StopPointInJourneyPattern) != count($a/passingTimes/TimetabledPassingTime)) then $a else ()",
826848
"SERVICE_JOURNEY_15",
827-
"ServiceJourney does not specify passing time for all StopPointInJourneyPattern"
849+
"ServiceJourney missing some passing times",
850+
"ServiceJourney does not specify passing time for all StopPointInJourneyPattern",
851+
Severity.ERROR
828852
)
829853
);
830854
validationTree.addValidationRule(
831855
new ValidateNotExist(
832856
"vehicleJourneys/ServiceJourney[@id = preceding-sibling::ServiceJourney/@id]",
833857
"SERVICE_JOURNEY_16",
834-
"ServiceJourney is repeated with a different version"
858+
"ServiceJourney multiple versions",
859+
"ServiceJourney is repeated with a different version",
860+
Severity.WARNING
835861
)
836862
);
837863

838864
validationTree.addValidationRule(
839865
new ValidateNotExist(
840866
"vehicleJourneys/DatedServiceJourney[not(OperatingDayRef)]",
841867
"DATED_SERVICE_JOURNEY_1",
842-
"Missing OperatingDayRef on DatedServiceJourney"
868+
"DatedServiceJourney missing OperatingDayRef",
869+
"Missing OperatingDayRef on DatedServiceJourney",
870+
Severity.ERROR
843871
)
844872
);
845873
validationTree.addValidationRule(
846874
new ValidateNotExist(
847875
"vehicleJourneys/DatedServiceJourney[not(ServiceJourneyRef)]",
848876
"DATED_SERVICE_JOURNEY_2",
849-
"Missing ServiceJourneyRef on DatedServiceJourney"
877+
"DatedServiceJourney missing ServiceJourneyRef",
878+
"Missing ServiceJourneyRef on DatedServiceJourney",
879+
Severity.ERROR
850880
)
851881
);
852882
validationTree.addValidationRule(
853883
new ValidateNotExist(
854884
"vehicleJourneys/DatedServiceJourney[count(ServiceJourneyRef) > 1]",
855885
"DATED_SERVICE_JOURNEY_3",
856-
"Multiple ServiceJourneyRef on DatedServiceJourney"
886+
"DatedServiceJourney multiple ServiceJourneyRef",
887+
"Multiple ServiceJourneyRef on DatedServiceJourney",
888+
Severity.ERROR
857889
)
858890
);
859891
validationTree.addValidationRule(
860892
new ValidateNotExist(
861893
"vehicleJourneys/DatedServiceJourney[@id = preceding-sibling::DatedServiceJourney/@id]",
862894
"DATED_SERVICE_JOURNEY_4",
863-
"DatedServiceJourney is repeated with a different version"
895+
"DatedServiceJourney multiple versions",
896+
"DatedServiceJourney is repeated with a different version",
897+
Severity.WARNING
864898
)
865899
);
866900
validationTree.addValidationRule(
867901
new ValidateNotExist(
868902
"vehicleJourneys/DatedServiceJourney/DatedServiceJourneyRef[@ref = preceding-sibling::DatedServiceJourneyRef/@ref]",
869903
"DATED_SERVICE_JOURNEY_5",
870-
"Multiple references from a DatedServiceJourney to the same DatedServiceJourney"
904+
"DatedServiceJourney multiple references to the same DatedServiceJourney",
905+
"Multiple references from a DatedServiceJourney to the same DatedServiceJourney",
906+
Severity.ERROR
871907
)
872908
);
873909

874910
validationTree.addValidationRule(
875911
new ValidateNotExist(
876912
"vehicleJourneys/DeadRun[not(passingTimes)]",
877913
"DEAD_RUN_1",
878-
"The Dead run does not reference passing times"
914+
"DeadRun missing PassingTime references",
915+
"The Dead run does not reference passing times",
916+
Severity.INFO
879917
)
880918
);
881919
validationTree.addValidationRule(
882920
new ValidateNotExist(
883921
"vehicleJourneys/DeadRun[not(JourneyPatternRef)]",
884922
"DEAD_RUN_2",
885-
"The Dead run does not reference a journey pattern"
923+
"DeadRun missing JourneyPattern references",
924+
"The Dead run does not reference a journey pattern",
925+
Severity.ERROR
886926
)
887927
);
888928
validationTree.addValidationRule(
889929
new ValidateNotExist(
890930
"vehicleJourneys/DeadRun[not(dayTypes/DayTypeRef)]",
891931
"DEAD_RUN_3",
892-
"The Dead run does not reference day types"
932+
"DeadRun missing DayType references",
933+
"The Dead run does not reference day types",
934+
Severity.ERROR
893935
)
894936
);
895937

896938
validationTree.addValidationRule(
897939
new ValidateNotExist(
898940
"vehicleJourneys/ServiceJourney/FlexibleServiceProperties[not(@id)]",
899941
"FLEXIBLE_SERVICE_1",
900-
"Missing id on FlexibleServiceProperties"
942+
"FlexibleService missing Id on FlexibleServiceProperties",
943+
"Missing id on FlexibleServiceProperties",
944+
Severity.ERROR
901945
)
902946
);
903947
validationTree.addValidationRule(
@@ -1184,6 +1228,7 @@ protected ValidationTree getVehicleScheduleFrameValidationTree(String path) {
11841228
new ValidateAtLeastOne(
11851229
"blocks/Block | blocks/TrainBlock",
11861230
"BLOCK_1",
1231+
"Block missing VehicleScheduleFrame",
11871232
"At least one Block or TrainBlock required in VehicleScheduleFrame",
11881233
Severity.ERROR
11891234
)

0 commit comments

Comments
 (0)