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

Proposal for schema (Redux mk. II) #438

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

johnnybubonic
Copy link

@johnnybubonic johnnybubonic commented Jul 20, 2020

NOTE: This is a total redo of #431 (and #437, oops - need to stop playing with branches I have open PRs for) to match the updated example in #279 as it progresses.


Hey all! I'm composing some XSDs for GTG.

Why?

This, combined with the porting to LXML (#401) (LXML natively supports XSD), will let you do some REALLY nice things programmatically:

  • Automatic data validation/verification
  • Automatic structure validation/verification
  • Automatic population of default attributes
  • Address and enforce concerns in Better XML format [RFC] #279 as they're implemented
  • Very easy test cases for generated XML

Review

I'd like someone more familiar with the GTG guts to give it a look over. Please review and reference the items marked:

<!--
  TODO: ...
-->

for specific questions/concerns/suggestions I have.

Outer scope changes

The gtg_tasks.xml (filename subject to change per #279 approval/implementation), etc. will need to have namespaces added.

e.g. for gtg_tasks.xml, instead of:

<?xml version="1.0" ?>
<gtgData appVersion="0.5" xmlVersion="2">
<!-- ... -->
</gtgData>

it'd be:

<?xml version="1.0" encoding="UTF-8" ?>
<gtgData appVersion="0.5"
         xmlVersion="2"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="https://wiki.gnome.org/Apps/GTG"
         xsi:schemaLocation="http://SOMEDOMAIN.TLD/SOME/PATH/TO/data.xsd">
<!-- ... -->
</project>

This can be done programmatically, and I can provide code to convert existing documents over to the namespaced version.

Implementation

I can provide examples of how to automatically detect, parse, fetch, and validate XSDs (and strip the namespace once the data/structure is validated/verified and defaults are applied, so the elements don't need to be referenced by namespace) with lxml, as I have direct experience with lxml in python3 and the above.

Further Reading

It is recommended to review #279 in full and take note of the example proposed document format. This PR will attempt to stay in tandem with current proposed format per #279, and will exit draft stage and enter a review/pulling stage once the specification in #279 hits master.

This was referenced Jul 20, 2020
currently matches getting-things-gnome#279. mostly (still in discussion re: CDATA vs. escaping in <content>).

all uniqueness and associations applied, i think, as well.
@johnnybubonic
Copy link
Author

johnnybubonic commented Jul 21, 2020

@diegogangl the schemas should now match the current proposed format for #279, with the EXCEPTION of still hashing out how to handle <content>.

if you'd like to validate yourself, you can do it without lxml- just make sure libxml2 is installed (which it almost assuredly is if you're using lxml), and do:

cd /tmp
git clone --single-branch --branch schema https://github.com/johnnybubonic/gtg.git r00t_gtg
cd r00t_gtg/data/schema
xmllint --noout --schema data.xsd /path/to/your/proposed/format.xml

The validation errors can be a little confusing, but they're pretty easily googled. If you get any, let me know. The only one I think you'll get is it choking on <content> unless you either escape the chars or enclose it in a CDATA. This one, specifically:

/tmp/data.xml:25: element content: Schemas validity error : Element '{https://wiki.gnome.org/Apps/GTG}content': Element content is not allowed, because the type definition is simple.
/tmp/data.xml:46: element content: Schemas validity error : Element '{https://wiki.gnome.org/Apps/GTG}content': Element content is not allowed, because the type definition is simple.
/tmp/data.xml fails to validate

Note that you need to change your closing tags in /gtgData/tasklist/task[0]/tags/tag items (<tag/> => </tag>) first, as that's not valid XML. ;) You'll also probably have to remove the space at the end of the tag IDs in those same elements.

You may need to enable the default namespace (per the snippet in comment 0 of this PR).

@diegogangl diegogangl added this to the 0.6 (The future) milestone Mar 13, 2021
@diegogangl
Copy link
Contributor

A couple of things to change here:

  • The icon is now a string with a single character (an emoji).
  • There's been some changes to the recurrent tasks stuff

I can send you a gtg_data.xml file if you want

@johnnybubonic
Copy link
Author

@diegogangl yeah, please send an updated gtg_data.xml! sorry for the delay.

@diegogangl
Copy link
Contributor

And of course I never sent you an updated xml -_-

Here it is:
https://gist.github.com/diegogangl/8f08a660c9453f49f4602d8bb36ceab1

@diegogangl diegogangl modified the milestones: 0.6 (The future), 0.7 Nov 15, 2021
@nekohayo nekohayo added maintainability Automated tests suite, tooling, refactoring, or anything that makes it easier for developers RFC "Request for Comments" brainstorming tickets for things we are unsure about labels Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement maintainability Automated tests suite, tooling, refactoring, or anything that makes it easier for developers RFC "Request for Comments" brainstorming tickets for things we are unsure about
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants