[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re[2]: [lmi] A validating schema for wxxrc?
From: |
Vadim Zeitlin |
Subject: |
Re[2]: [lmi] A validating schema for wxxrc? |
Date: |
Sun, 10 Jun 2007 22:37:25 +0200 |
On Sun, 10 Jun 2007 22:31:09 +0200 Evgeniy Tarassov <address@hidden> wrote:
ET> On 6/8/07, Greg Chicares <address@hidden> wrote:
ET> >
ET> > Here's another example, using the same file:
ET> >
ET> > - <bitmap>basicdlg.xpm</bitmap>
ET> > + <bitmap>basicdlg.XPM</bitmap>
ET> >
ET> > Suppose that such an X pixmap exists, and its name is all lowercase.
ET> > Maybe it works under msw (just a guess), but won't under GNU/Linux.
ET> > Or suppose it were misspelled as, say, 'basicdlg.xmp': that's a typo
ET> > of which I know I'm capable.
ET>
ET> It is very nice feature to have, but AFAIK it is not possible (in WXS
ET> neither in RNG) to access filesystem information. But as you have
ET> mentioned -- probably the best place to do such a validation would be
ET> to check for files in C++ when the XRC files is first loaded:
ET> wxXmlResource::Get()->Load("XXX.xrc");
This also applies to the question about mistyping the ids in XRC -- there
is nothing we can do about this at XRC level as the validator doesn't have
access to C++ code and so can't know that the id is mistyped.
ET> > Here's an example of a few things that I guess would be caught at
ET> > runtime, if someone actually loads this particular dialog, but which
ET> > might be better to catch in a schema:
ET> >
ET> > wxWidgets-2.8.3/samples/xrc/rc/derivdlg.xrc
ET> >
ET> > 37 <object class="sizeritem">
ET> > 38 <flag>wxALIGN_CENTRE|wxALL</flag>
ET> > 39 <border>5</border>
ET> > 40 <object class="wxCheckBox" name="my_checkbox">
ET> > 41 <label>Enable listbox</label>
ET> > 42 </object>
ET> > 43 </object>
ET> >
ET> > Let me mangle that:
ET> >
ET> > <Objekt Klass="WxSizerItem">
ET> > <flag>WxALIGN_IN_THE_CENTRE|wxBCE</flag>
ET> > <border>cinq</border>
ET> > <objet classe="wxChequeBox" nom="my_checkbox">
ET> >
ET> > I guess I don't often make mistakes like that, and I find them
ET> > soon enough; but a schema would probably find them sooner, if I
ET> > routinely used it before committing any wxxrc file.
ET>
ET> That indeed would be a really good feature to have. Myself, I'm a
ET> person that does a lot of errors (typing or spelling errors), that's
ET> why working with XRC for me is rather painful experience (compared to
ET> other tasks).
Most of the errors above OTOH should be caught by the validation:
1. "Objekt" (invalid tag name) definitely will
2. Assuming it's corrected to "object", both missing (required) "class"
attribute and the unknown "Klass" one will be detected too
3. <flag> contents will be validated too
4. non-numeric <border> argument should be caught (except it can also be
expressed in dialog units so it's not as simple as checking for whether
it's a number but the point is that it will still be caught)
The "wxChequeBox" won't be a fatal error however as it could be a custom
class. Hopefully there should be a warning along the lines of "unable to
validate the contents of a custom class without custom schema" for it
though.
Regards,
VZ