Closed wangf1122 closed 9 months ago
I tested the code and the error is not displayed in the form like it should be. It is only displayed in the validation section.
I would expect something like the following:
May want to consider creating a new rule like the following
<!-- Creation/revision dates compare -->
<sch:rule context="//gmd:identificationInfo/*/gmd:citation/gmd:CI_Citation/gmd:date/gmd:CI_Date[gmd:dateType/gmd:CI_DateTypeCode/@codeListValue = 'RI_367']/gmd:date
|//*[@gco:isoType='gmd:MD_DataIdentification']/gmd:citation/gmd:CI_Citation/gmd:date/gmd:CI_Date[gmd:dateType/gmd:CI_DateTypeCode/@codeListValue = 'RI_367']/gmd:date
|//*[@gco:isoType='srv:SV_ServiceIdentification']/gmd:citation/gmd:CI_Citation/gmd:date/gmd:CI_Date[gmd:dateType/gmd:CI_DateTypeCode/@codeListValue = 'RI_367']/gmd:date">
<sch:let name="creationDate" value="../../../gmd:date/gmd:CI_Date[gmd:dateType/gmd:CI_DateTypeCode/@codeListValue = 'RI_366']/gmd:date/gco:Date" />
<sch:let name="missingCreation" value="not(string($creationDate))" />
<sch:let name="publicationDate" value="gco:Date" />
<sch:let name="missingPublication" value="not(string($publicationDate))" />
<sch:assert test="$missingPublication or $missingCreation or XslUtilHnap:compareDates($publicationDate, $creationDate) >= 0 ">$loc/strings/PublicationDateBeforeCreationDate</sch:assert>
</sch:rule>
With that code, it display the rule in the form.
The only issue was when I double clicked on the message from the validation section - it was not going to the error message in the form - maybe you can look into that issue - but if it is causing issues we can look at it later.
@ianwallen
The code looks good.
I will update the PR with this block of code
@josegar74
The gco:DateTime was nested into the gmd:date. Doesn't looks it's necessary.
@wangf1122 I just did a test and the following validated and it should have failed. - I'm guessing that this is what @josegar74 was referring too.
@ianwallen @josegar74
I have added the xpath and util Java function to handle both gco:Date and gco:DateTime. I did test locally and they are acceptable.
1) No validation error.
2) Validation error.
@wangf1122
Can you explain why you feel you have to create a new function compareDateTimes
The Extents date validation is able to handle all 3 date formats without any issues that I could see?
I tested modifying my previous sample to the following and it seemed to have worked
<!-- Creation/revision dates compare -->
<sch:rule context="//gmd:identificationInfo/*/gmd:citation/gmd:CI_Citation/gmd:date/gmd:CI_Date[gmd:dateType/gmd:CI_DateTypeCode/@codeListValue = 'RI_367']/gmd:date
|//*[@gco:isoType='gmd:MD_DataIdentification']/gmd:citation/gmd:CI_Citation/gmd:date/gmd:CI_Date[gmd:dateType/gmd:CI_DateTypeCode/@codeListValue = 'RI_367']/gmd:date
|//*[@gco:isoType='srv:SV_ServiceIdentification']/gmd:citation/gmd:CI_Citation/gmd:date/gmd:CI_Date[gmd:dateType/gmd:CI_DateTypeCode/@codeListValue = 'RI_367']/gmd:date">
<sch:let name="creationDate" value="../../../gmd:date/gmd:CI_Date[gmd:dateType/gmd:CI_DateTypeCode/@codeListValue = 'RI_366']/gmd:date" />
<sch:let name="missingCreation" value="not(string($creationDate))" />
<sch:let name="publicationDate" value="." />
<sch:let name="missingPublication" value="not(string($publicationDate))" />
<sch:assert test="$missingPublication or $missingCreation or XslUtilHnap:compareDates($publicationDate, $creationDate) >= 0 ">$loc/strings/PublicationDateBeforeCreationDate</sch:assert>
</sch:rule>
Another variation of the fix could be the following
<!-- Creation/revision dates compare -->
<sch:rule context="//gmd:identificationInfo/*/gmd:citation/gmd:CI_Citation/gmd:date/gmd:CI_Date[gmd:dateType/gmd:CI_DateTypeCode/@codeListValue = 'RI_367']/gmd:date
|//*[@gco:isoType='gmd:MD_DataIdentification']/gmd:citation/gmd:CI_Citation/gmd:date/gmd:CI_Date[gmd:dateType/gmd:CI_DateTypeCode/@codeListValue = 'RI_367']/gmd:date
|//*[@gco:isoType='srv:SV_ServiceIdentification']/gmd:citation/gmd:CI_Citation/gmd:date/gmd:CI_Date[gmd:dateType/gmd:CI_DateTypeCode/@codeListValue = 'RI_367']/gmd:date">
<sch:let name="creationDate" value="../../../gmd:date/gmd:CI_Date[gmd:dateType/gmd:CI_DateTypeCode/@codeListValue = 'RI_366']/gmd:date/gco:Date
|../../../gmd:date/gmd:CI_Date[gmd:dateType/gmd:CI_DateTypeCode/@codeListValue = 'RI_366']/gmd:date/gco:DateTime" />
<sch:let name="missingCreation" value="not(string($creationDate))" />
<sch:let name="publicationDate" value="gco:Date|gco:DateTime" />
<sch:let name="missingPublication" value="not(string($publicationDate))" />
<sch:assert test="$missingPublication or $missingCreation or XslUtilHnap:compareDates($publicationDate, $creationDate) >= 0 ">$loc/strings/PublicationDateBeforeCreationDate</sch:assert>
</sch:rule>
I have tested both and they seem to fix the issue raised by @josegar74
@ianwallen @josegar74
I have copy pasted Ian's code and it works fine with local test.
I believe all feedback has been accounted for here.
I would expect that there should only be one creation date. But I believe it may be possible to have multiple publication dates.
For now, maybe <sch:let name="creationDate
could be modified to get the first occurrence so that if it does happen users will still be able validate the record without getting an array issues.
We can create another issue that can look into validating the number of occurrences of the creation date. We would need to look into HNAP to see if it allows multiple creation dates - if not then we can add a check to fail validation if multiple creation dates are added.
@ianwallen @josegar74
I have update the code to use first creation date which is /gmd:date[1]/gco:Date[1]. It does not cause harm to our case but will also handle if this element is an array.
If publication date is before creation date.![image](https://github.com/metadata101/iso19139.ca.HNAP/assets/74916635/8e25c8ff-3f20-4634-b88a-985e3b09d5b4)
then there will be validation error![image](https://github.com/metadata101/iso19139.ca.HNAP/assets/74916635/7efd9c3c-ea60-48c4-b065-2e01e20ce6c2)