[relaxng-user] Modules, start patterns, driver files, trang - sanity check

David Rosenborg darolst at pantor.com
Mon Feb 23 14:42:19 ICT 2004


Hi Sean,

Multiple start patterns (definitions in general) are only allowed if you
specify a combine attribute. In the compact syntax you would
use the |= or &= operator as in:

include "A.rnc" { start |= notAllowed }
include "B.rnc" { start |= notAllowed }

AB = element ab { a, b }
start |=  AB

This translates into a start pattern where only AB is allowed.

Cheers,
David

Sean McGrath wrote:

> All,
>
> I'm soliciting advise on how best to implement Relax modules that are 
> both usable "standalone" and usable as modules in larger modules and 
> larger standalone schemas.
>
> My first thought was to give each module its own start pattern. So, 
> lets say I have modules A and B that I wish to use standalone and also 
> as parts of a bigger module AB.
>
>         1) I give each module a start pattern.
>
>         2) When I include a module in a larger module, I override its 
> start pattern
>
> Example:
>
> File A.rnc - a standalone schema and a module
>         A = element a { text }
>         start = A
>
> File B.rnc - a standalone schema and a module
>         B = element b { text }
>         start = B
>
> File AB.rnc - a standalone schema and a module. It includes two 
> sub-modules, A and B
>         include "a.rnc" { start = AB }
>         include "b.rnc" { start = AB }
>
>         AB = element ab { A , B }
>         start = AB
>
> However, trang complains with this approach, when generating XSD's:
>         - multiple definitions of "#start" without "combine" attribute
>
> If it is the case that I can only override the start pattern once per 
> schema, then I can switch to using driver schemas.
>         1) Do not put a start pattern into any module
>
>         2) Create a "driver" schema  that includes the module and 
> provides a start pattern
>
>
> Example:
>
> File A.rnc - a module
>         A = element a { text }
>
> File A_driver.rnc - driver file to make schema A work standalone
>         include "A.rnc"
>         start = A
>
> File B.rnc - a module
>         B = element b { text }
>
> File B_driver.rnc - driver file to make schema B work standalone
>         include "B.rnc"
>         start = B
>
> File AB.rnc - a module that includes two sub-modules, A and B
>         include "a.rnc"
>         include "b.rnc"
>
>         AB = element ab { A , B }
>
> File AB_driver.rnc - driver file to make schema AB work standalone
>         include "AB.rnc"
>         start = AB
>
> Am I correct that the start patten can only be overridden once per 
> schema? Is the driver approach a good way to go or are there better 
> alternatives?
>
> regards,
>
> Sean McGrath
> http://seanmcgrath.blogspot.com
>
> _______________________________________________
> relaxng-user mailing list
> relaxng-user at relaxng.org
> http://relaxng.org/mailman/listinfo/relaxng-user




More information about the relaxng-user mailing list