README 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. Schema for Validation of XRC files
  2. ==================================
  3. 0. Overview
  4. -----------
  5. The files in this directory allow you to check correctness of the XRC files by
  6. verifying that their contents conforms to wxWidgets XRC schema. Doing this is a
  7. good way to detect some common errors in manually-written XRC files, even
  8. though it doesn't currently detect all the possible errors.
  9. 1. Installation
  10. ---------------
  11. To use them, you need to install Jing, a RELAX NG validator, on your system.
  12. Jing is available from http://www.thaiopensource.com/relaxng/jing.html and is a
  13. Java program, so it requires a working Java Runtime Environment installation.
  14. If you are using Windows and already have a working JRE, you can download Jing
  15. packaged as a Windows executable from
  16. http://sourceforge.net/projects/wxwindows/files/tools/jing.zip/download
  17. 2. Usage
  18. --------
  19. Once you have a working version of Jing, you can use it directly as following:
  20. jing -c http://www.wxwidgets.org/wxxrc your-file.xrc
  21. Alternatively, you can also use wxrc --validate or --validate-only options:
  22. wxrc --validate-only your-file.xrc
  23. (notice that this still requires jing to be installed).
  24. 3. Customization
  25. ----------------
  26. Using xrc_schema.rnc only validates the standard wxWidgets classes and skips
  27. any custom ones, for which you might have your own XRC handlers defined. If
  28. you don't use any custom XRC handlers at all, you may prefer to use
  29. xrc_schema_builtin_only.rnc schema instead of xrc_schema.rnc which won't accept
  30. any non-standard classes at all -- this is useful for detecting any typos.
  31. If you do use your own custom classes, then you need to define your own
  32. validations rules for them. Please see comments in xrc_schema.rnc for more
  33. details about how to do it, but here is a motivating example showing that it is
  34. not too difficult to validate your own classes:
  35. #
  36. # RELAX NG schema for extended XRC with support for custom handlers.
  37. #
  38. default namespace = "http://www.wxwidgets.org/wxxrc"
  39. namespace xrc = "http://www.wxwidgets.org/wxxrc"
  40. include "http://www.wxwidgets.org/wxxrc" {
  41. customClasses = RoundingButtons | InputSequenceEntry
  42. }
  43. # Simplest possible example: no special properties for this handler.
  44. RoundingButtons =
  45. element object {
  46. attribute class { "RoundingButtons" } &
  47. stdObjectNodeAttributes &
  48. stdWindowProperties
  49. }
  50. # This handler has an optional property called "title" containing text.
  51. InputSequenceEntry =
  52. element object {
  53. attribute class { "InputSequenceEntry" } &
  54. stdObjectNodeAttributes &
  55. stdWindowProperties &
  56. [xrc:p="o"] element title {_, t_text }*
  57. }
  58. To use a custom schema, you need to pass the full path to the local file
  59. containing it to Jing or use wxrc --xrc-schema command line option, so you
  60. could do, for example:
  61. jing -c $(WXWIN)/misc/schema/xrc_schema_builtin_only.rnc your-file.xrc
  62. or
  63. wxrc --validate-only --xrc-schema=my_custom.rnc your-file.xrc