Skip to content
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

tighten the XSD #279

Open
VladimirAlexiev opened this issue May 18, 2021 · 4 comments
Open

tighten the XSD #279

VladimirAlexiev opened this issue May 18, 2021 · 4 comments
Assignees
Labels
validation Validation of EPCIS data

Comments

@VladimirAlexiev
Copy link
Contributor

VladimirAlexiev commented May 18, 2021

@RalphTro @CraigRe who are the main devs of the XSD?

The XSD allows various empty lists and empty strings, and I don't see the rationale for this.
@dakbhavesh compensates this in #255 using Schematron.
But when it comes to single fields, it's better to tighten the XSD rather than defer to Schematron. Eg:

  • epcList is required but can be empty, why? This can be fixed by changing minOccurs as follows:
      <xsd:extension base="epcis:EPCISEventType">
        <xsd:sequence>
          <xsd:element name="epcList" type="epcis:EPCListType" minOccurs="0"/>
  <xsd:complexType name="EPCListType">
    <xsd:sequence>
      <xsd:element name="epc" type="epcglobal:EPC" minOccurs="1" maxOccurs="unbounded"/>
  • epc can be the empty string, why? Add a minLength facet in the code below:
		<xsd:simpleContent>
			<xsd:extension base="xsd:string"/>

Consider switching to RNC? (this idea was canceled quickly)

https://balisage.net/Proceedings/vol7/html/Lee01/BalisageVol7-Lee01.html example "equivalent schema in XSD using Annotations instead of comments" shows how much nicer is RNC compared to XSD, and #276 ​asks: is there any chance the group could adopt RNC as XML master schema?

  • We have an open source RNC validator (branch of jing) that produces precise XPath info of the error, allowing a user to pinpoint it and to highlight it, similar to what Schematron does and allowing unified error diagnostics. I don't know of a XSD validator to output XPath error location.
  • I can convert XSD to RNC using tools from https://github.com/VladimirAlexiev/rnc
  • The opposite conversion is also easy

@dakbhavesh:

You can express (epcList and epcList/epc) more simply as epcList/epc: you cannot reach the inner element if the outer element is missing.

About string-length(epcList/epc) > 0: think this checks one epc not necessarily all. I think you have to do something like this:

  • assert epclist/epc and count(epclist/epc)=count(epclist/epc[string-length()>0])
  • or if Schematron has "negated assert" then raise error on epclist/epc=""
@dakbhavesh
Copy link
Collaborator

Thanks, @VladimirAlexiev for improving the assertion and make it concise but needs a bit of correction to make it work. Regarding "negated assert" I tried following and it worked.

<sch:report test="epcList/epc[string-length(text()) = 0]">
      all elements in epcList must be non-empty
</sch:report>

report - triggers when the condition evaluates to true
assert - triggers when the condition evaluates to false

above is POC of what's all possible with Schematron

@CraigRe CraigRe added the validation Validation of EPCIS data label May 18, 2021
@VladimirAlexiev
Copy link
Contributor Author

@dakbhavesh Isn't epclist/epc='' simpler?

@dakbhavesh
Copy link
Collaborator

I tried epclist/epc='' on http://xpather.com/ to but it wasn't able to detect the empty <epc> tags under epcList

@CraigRe
Copy link
Collaborator

CraigRe commented May 18, 2021

EVERYONE check epcis 2.0 xsd, where anyuri, check to eliminate loophole for empty string, i.e., sting lengths should be nonzero. Minlength > 0 , provided that enclosing xml element is ITSELF optional within ITS enclosing xml element.
i.e., minoccurs = 0 , in order to avoid empty strings like this:
image

@VladimirAlexiev VladimirAlexiev changed the title tighten the XSD, consider switching to RNC tighten the XSD Jun 17, 2021
@dakbhavesh dakbhavesh self-assigned this Sep 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
validation Validation of EPCIS data
Projects
None yet
Development

No branches or pull requests

4 participants