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

XEP-0060: Add integer-or-max datatype to use with Data Forms Validation #988

Closed
wants to merge 1 commit into from

Conversation

Ppjet6
Copy link
Contributor

@Ppjet6 Ppjet6 commented Sep 24, 2020

I'd like to have council's opinion on how to handle this.

Seems like the datatype requires a prefix, where to define it? where do I put things so that they end up in https://xmpp.org/registrar/xdv-prefixes.html ? In 0060 as well?

Should this type be its own spec? And then referred to and given meaning in 0060?

Rendered version

Signed-off-by: Maxime “pep” Buquet pep@bouah.net

@Ppjet6 Ppjet6 added the Needs Council The affected XEP has the Council as Approving Body and it needs to decide on the change. label Sep 24, 2020
@Ppjet6 Ppjet6 force-pushed the 0060-integer-or-max-type branch 4 times, most recently from 1051b5e to 02b21ce Compare September 25, 2020 12:42
@Ppjet6
Copy link
Contributor Author

Ppjet6 commented Sep 25, 2020

@horazont
Copy link
Contributor

horazont commented Oct 13, 2020

I looked at this from a XML schema perspective, and I think there are formal issues here.

I think the bare minimum would be to re-write this as:

<?xml version="1.0"?>
<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' targetNamespace='urn:foo:bar'>
  <xs:simpleType name='integer-or-max'>
    <xs:union>
      <xs:simpleType>
        <xs:restriction base='xs:integer'/>
      </xs:simpleType>
      <xs:simpleType>
        <xs:restriction base='xs:string'>
          <xs:enumeration value='max'/>
        </xs:restriction>
      </xs:simpleType>
    </xs:union>
  </xs:simpleType>
</xs:schema>

(with a proper namespace of course).

The xs: is, at this point, mostly convention I think. However, the targetNamespace is required to import the Schema into another Schema -- which is the only way to cross-reference Schemas across documents. The targetNamespace needs to match the namespace on the xs:import directive and it must not be empty.

If you put the above in /tmp/foo.xsd, you could put this down as bar.xsd:

<?xml version="1.0"?>
<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'
           xmlns:foo='urn:foo:bar'>
  <xs:import namespace="urn:foo:bar" schemaLocation="file:///tmp/foo.xsd"/>
  <xs:element name='size' type='foo:integer-or-max'/>
</xs:schema>

And then you could validate this XML file (foo.xml):

<size>max</size>

using xmllint like this:

$ xmllint --schema bar.xsd foo.xml
<?xml version="1.0"?>
<size>max</size>
foo.xml validates

Edit: Feel free to trim it down further, as long as the bar.xsd use-case still works. I think that’s the minimum smoke test we need to do for a schema to be useful.

@horazont horazont removed the Needs Council The affected XEP has the Council as Approving Body and it needs to decide on the change. label Oct 20, 2020
@horazont horazont force-pushed the 0060-integer-or-max-type branch 2 times, most recently from bd1dab9 to 7b25781 Compare March 8, 2021 20:00
@horazont
Copy link
Contributor

horazont commented Mar 8, 2021

fixe.

@horazont horazont added the Ready To Merge No acknowledgements of other parties are needed anymore. There may be changes to do at merge time. label Mar 8, 2021
@horazont horazont assigned horazont and unassigned Ppjet6 Mar 8, 2021
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
@horazont
Copy link
Contributor

Merged as b7fe8d8, but github doesn't know :)

@horazont horazont closed this Aug 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ready To Merge No acknowledgements of other parties are needed anymore. There may be changes to do at merge time.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants