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

Implement Object checking for allowed children #49

Open
ahankinson opened this issue Nov 9, 2011 · 7 comments
Open

Implement Object checking for allowed children #49

ahankinson opened this issue Nov 9, 2011 · 7 comments

Comments

@ahankinson
Copy link
Member

In the generated code, we should use the ODD models to ensure that any children that are being added to an object are allowed by the schema. Currently any object is allowed to be a child of any other object, which doesn't always make sense.

@ghost ghost assigned ahankinson Nov 9, 2011
@zolaemil
Copy link
Contributor

Is there any updates on this?

I realise that ensuring the validity agains a custom schema is a complex problem. But one more little step in addition to checking for allowed children would be to ensure that the children are coming in the allowed order.

@ahankinson
Copy link
Member Author

I'm increasingly not inclined to implement this, for a couple reasons. The first is architectural: the customization functionality of libmei is the most complex part of it, conceptually, and I've seen a lot of problems with people who don't understand the relationship between the ODD and the library. Because of the nature of this code (as a library) the only real thing we can do is raise an exception on a failure (since we can't "gracefully recover" from wrong input) so that would add an additional amount of frustration.

The second, more practical reason, is things like this it's already implemented in the RelaxNG schema. It's really easy to validate a test set of software against the RelaxNG schema, so it would be duplicating this for no real good reason.

You can use Schematron rules to validate things like order within tags.

@zolaemil
Copy link
Contributor

I admit I haven't even used the customization functionality, just coming across issues when it would be useful.

Yes, you can validate with Schematron after the MEI is exported, but that's a bit too late. Ideal would be if we could write code like this:

fileDesc.addChild(pubStmt)
fileDesc.addChild(titleStmt)

and it would still become a valid MEI (i.e. with children in the correct order, titleStmt first, then pubStmt). I do realise we aren't living in an ideal world :(

@ahankinson
Copy link
Member Author

Yeah, that's not going to happen. There's just way too many possibilities, and would probably just serve to frustrate rather than help.

@lpugin
Copy link
Member

lpugin commented Sep 12, 2014

I am not sure I understand the problem/question, but it seems to be that
one option would be to modify libmei so it does not generate an addChild
method but instead an addSomething for every child allowed. For example:

fileDesc.addPubStmt( stmt )
fileDesc.addTitleStmt( stmt )

Laurent

On Fri, Sep 12, 2014 at 4:42 PM, Zoltan Komives [email protected]
wrote:

I admit I haven't even used the customization functionality, just coming
across issues when it would be useful.

Yes, you can validate with Schematron after the MEI is exported, but
that's a bit too late. Ideal would be if we could write code like this:

fileDesc.addChild(pubStmt)
fileDesc.addChild(titleStmt)

and it would still become a valid MEI (i.e. with children in the correct
order, titleStmt first, then pubStmt). I do realise we aren't living in
an ideal world :P


Reply to this email directly or view it on GitHub
#49 (comment).

@lpugin
Copy link
Member

lpugin commented Sep 12, 2014

What I meant is that addTitleStmt would be generated only if titleStmt is
allowed as direct child, of course. Then the other issue is the
order/number of the children...

On Fri, Sep 12, 2014 at 4:57 PM, Andrew Hankinson [email protected]
wrote:

Yeah, that's not going to happen. There's just way too many possibilities,
and would probably just serve to frustrate rather than help.


Reply to this email directly or view it on GitHub
#49 (comment).

@ahankinson
Copy link
Member Author

stmt would likely have to be another data type, not an MeiElement object, but containing attributes and, possibly, other children.

If you really want to, validation can take place in your own software prior to saving, e.g.,

foo = meiDocumentToString(doc)
valid = validate(foo)
if valid:
    writetofile(foo)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants