wxWidgets/misc/schema
tm 7ce3693956 Add support for bitmaps to wxToggleButton XRC handler
Handle "bitmap" and "bitmapposition" attributes in wxToggleButton XRC handler,
just as it's already done for wxBitmap and wxBitmapToggleButton.

Closes #17850.
2017-05-28 16:05:38 +02:00
..
README Add a simple README for the XRC schemas. 2013-10-18 11:21:12 +00:00
xrc_schema_builtin_only.rnc Add RELAX NG schema for XRC files. 2013-10-03 11:08:57 +00:00
xrc_schema.rnc Add support for bitmaps to wxToggleButton XRC handler 2017-05-28 16:05:38 +02:00

                      Schema for Validation of XRC files
                      ==================================

0. Overview
-----------

The files in this directory allow you to check correctness of the XRC files by
verifying that their contents conforms to wxWidgets XRC schema. Doing this is a
good way to detect some common errors in manually-written XRC files, even
though it doesn't currently detect all the possible errors.


1. Installation
---------------

To use them, you need to install Jing, a RELAX NG validator, on your system.
Jing is available from http://www.thaiopensource.com/relaxng/jing.html and is a
Java program, so it requires a working Java Runtime Environment installation.

If you are using Windows and already have a working JRE, you can download Jing
packaged as a Windows executable from

    http://sourceforge.net/projects/wxwindows/files/tools/jing.zip/download


2. Usage
--------

Once you have a working version of Jing, you can use it directly as following:

    jing -c http://www.wxwidgets.org/wxxrc your-file.xrc

Alternatively, you can also use wxrc --validate or --validate-only options:

    wxrc --validate-only your-file.xrc

(notice that this still requires jing to be installed).


3. Customization
----------------

Using xrc_schema.rnc only validates the standard wxWidgets classes and skips
any custom ones, for which you might have your own XRC handlers defined. If
you don't use any custom XRC handlers at all, you may prefer to use
xrc_schema_builtin_only.rnc schema instead of xrc_schema.rnc which won't accept
any non-standard classes at all -- this is useful for detecting any typos.

If you do use your own custom classes, then you need to define your own
validations rules for them. Please see comments in xrc_schema.rnc for more
details about how to do it, but here is a motivating example showing that it is
not too difficult to validate your own classes:

    #
    # RELAX NG schema for extended XRC with support for custom handlers.
    #

    default namespace = "http://www.wxwidgets.org/wxxrc"
    namespace xrc = "http://www.wxwidgets.org/wxxrc"

    include "http://www.wxwidgets.org/wxxrc" {
        customClasses = RoundingButtons | InputSequenceEntry
    }

    # Simplest possible example: no special properties for this handler.
    RoundingButtons =
        element object {
            attribute class { "RoundingButtons" } &
            stdObjectNodeAttributes &
            stdWindowProperties
        }

    # This handler has an optional property called "title" containing text.
    InputSequenceEntry =
        element object {
            attribute class { "InputSequenceEntry" } &
            stdObjectNodeAttributes &
            stdWindowProperties &
            [xrc:p="o"] element title {_, t_text }*
        }


To use a custom schema, you need to pass the full path to the local file
containing it to Jing or use wxrc --xrc-schema command line option, so you
could do, for example:

    jing -c $(WXWIN)/misc/schema/xrc_schema_builtin_only.rnc your-file.xrc

or

    wxrc --validate-only --xrc-schema=my_custom.rnc your-file.xrc