-
-
Notifications
You must be signed in to change notification settings - Fork 489
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
option to force xsd schema check for required field #8294
base: main
Are you sure you want to change the base?
option to force xsd schema check for required field #8294
Conversation
@@ -102,6 +102,9 @@ | |||
|
|||
<xsl:param name="isReadOnly" required="no" as="xs:boolean" select="false()"/> | |||
|
|||
<!-- Forcing the check for xsd schema for required field --> | |||
<xsl:param name="forceXsdSchemaCheck" required="no" as="xs:boolean" select="true()"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rename it to forceParentElementXsdSchemaCheck
as the XSD is checked independently of this flag in https://github.com/geonetwork/core-geonetwork/pull/8294/files#diff-dd05931fe2e9562f24fd5ced36ad129469606fad5f2aac2cdc97da357e5d99bcR121
Another more radical it can be just rely on the labels.xml
file condition
element, but probably will be confusing. It seems more suitable to implement this in a new version, not for 4.4 or 4.2
<xsl:variable name="elementCondition" select="gn-fn-metadata:getLabel($schema, name(),
$labels, name(..),$isoType, $xpath)/condition" />
<xsl:variable name="isRequired" as="xs:boolean">
<xsl:choose>
<xsl:when test="$elementCondition = 'mandatory'">
<xsl:value-of select="true()"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="false()"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about using the element condition to and a new option called "optional" that would override the XSD?
Something like the following? If someone specify the condition as mandatory or optional then it could override the XSD.
It seems like this would be less radical and would cause less impact.
<xsl:variable name="elementCondition" select="gn-fn-metadata:getLabel($schema, name(),
$labels, name(..),$isoType, $xpath)/condition" />
<xsl:variable name="isRequired" as="xs:boolean">
<xsl:choose>
<xsl:when test="$elementCondition = 'mandatory'">
<xsl:value-of select="true()"/>
</xsl:when>
<xsl:when test="$elementCondition = 'optional'">
<xsl:value-of select="false()"/>
</xsl:when>
// If not defined then set it to empty value to use default from schema definition.
<xsl:otherwise>
<xsl:value-of select="''"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
Then we would just add the condition of optional?
<condition>optional</condition>
This feature and extra param in the render-element function gives option for the sub schema to either force xsd check for required field or not.