PREFIX sx: <http://www.w3.org/ns/shex#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

[] a sx:Schema ;
    sx:shapes (<http://a.example/A> <http://a.example/B> <http://a.example/C> <http://a.example/D> <http://a.example/E> <http://a.example/F> <http://a.example/G> <http://a.example/H> <http://a.example/I> <http://a.example/J>) .

<http://a.example/A> a sx:ShapeDecl ;
    sx:abstract true ;
    sx:shapeExpr [ a sx:ShapeAnd ;
        sx:shapeExprs (
            [ a sx:NodeConstraint ;
                sx:pattern "sA..........$"
            ]
            [ a sx:Shape ;
                sx:expression [ a sx:TripleConstraint ;
                    sx:predicate <http://a.example/p>  ;
                    sx:valueExpr [ a sx:NodeConstraint ;
                        sx:values (0 1 2 3 4 5 6 7 8 9)
                    ];
                    sx:min 1;
                    sx:max -1
                ]
            ]
        )
    ] .

<http://a.example/B> a sx:ShapeDecl ;
    sx:abstract true ;
    sx:shapeExpr [ a sx:ShapeAnd ;
        sx:shapeExprs (
            [ a sx:Shape ; sx:extends ( <http://a.example/A> ) ]
            [ a sx:NodeConstraint ;
                sx:pattern "s.B.........$"
            ]
            [ a sx:Shape ;
                sx:expression [ a sx:TripleConstraint ;
                    sx:predicate <http://a.example/p>  ;
                    sx:valueExpr [ a sx:NodeConstraint ;
                        sx:values (0 1 3 4 5 6 7 8 9)
                    ];
                    sx:min 1;
                    sx:max -1
                ]
            ]
        )
    ] .

<http://a.example/C> a sx:ShapeDecl ; sx:shapeExpr [ a sx:ShapeAnd ;
    sx:shapeExprs (
        [ a sx:NodeConstraint ;
            sx:pattern "s..C........$"
        ]
        [ a sx:Shape ;
            sx:expression [ a sx:TripleConstraint ;
                sx:predicate <http://a.example/p>  ;
                sx:valueExpr [ a sx:NodeConstraint ;
                    sx:values (0 1 2 4 5 6 7 8 9)
                ];
                sx:min 1;
                sx:max -1
            ]
        ]
    ) ] .

<http://a.example/D> a sx:ShapeDecl ;
    sx:abstract true ;
    sx:shapeExpr [ a sx:ShapeAnd ;
        sx:shapeExprs (
             [ a sx:Shape ; sx:extends ( <http://a.example/B> ) ]
            <http://a.example/C>
            [ a sx:NodeConstraint ;
                sx:pattern "s...D.......$"
            ]
            [ a sx:Shape ;
                sx:expression [ a sx:TripleConstraint ;
                    sx:predicate <http://a.example/p>  ;
                    sx:valueExpr [ a sx:NodeConstraint ;
                        sx:values (0 1 2 3 5 6 7 8 9)
                    ];
                    sx:min 1;
                    sx:max -1
                ]
            ]
        )
    ] .

<http://a.example/E> a sx:ShapeDecl ;
    sx:abstract true ;
    sx:shapeExpr [ a sx:ShapeAnd ;
        sx:shapeExprs (
            [ a sx:NodeConstraint ;
                sx:pattern "s....E......$"
            ]
            [ a sx:Shape ;
                sx:extends (<http://a.example/D>) ;
                sx:expression [ a sx:TripleConstraint ;
                    sx:predicate <http://a.example/p>  ;
                    sx:valueExpr [ a sx:NodeConstraint ;
                        sx:values (2)
                    ]
                ]
            ]
        )
    ] .

<http://a.example/F> a sx:ShapeDecl ; sx:shapeExpr [ a sx:ShapeAnd ;
    sx:shapeExprs (
        [ a sx:NodeConstraint ;
            sx:pattern "s.....F.....$"
        ]
        [ a sx:Shape ;
            sx:expression [ a sx:TripleConstraint ;
                sx:predicate <http://a.example/p>  ;
                sx:valueExpr [ a sx:NodeConstraint ;
                    sx:values (3)
                ]
            ]
        ]
    ) ].

<http://a.example/G> a sx:ShapeDecl ;
    sx:abstract true ;
    sx:shapeExpr [ a sx:ShapeAnd ;
        sx:shapeExprs (
            [ a sx:NodeConstraint ;
                sx:pattern "s......G....$"
            ]
            [ a sx:Shape ;
                sx:extends (<http://a.example/E> <http://a.example/F>) ;
                sx:expression [ a sx:TripleConstraint ;
                    sx:predicate <http://a.example/p>  ;
                    sx:valueExpr [ a sx:NodeConstraint ;
                        sx:values (4)
                    ]
                ]
            ]
        )
    ] .

<http://a.example/H> a sx:ShapeDecl ;
    sx:abstract true ;
    sx:shapeExpr [ a sx:ShapeAnd ;
        sx:shapeExprs (
            [ a sx:Shape ; sx:extends ( <http://a.example/G> ) ]
            [ a sx:NodeConstraint ;
                sx:pattern "s.......H...$"
            ]
            [ a sx:Shape ;
                sx:expression [ a sx:TripleConstraint ;
                    sx:predicate <http://a.example/p>  ;
                    sx:valueExpr [ a sx:NodeConstraint ;
                        sx:values (0 1 2 3 4 5 8 9)
                    ];
                    sx:min 0;
                    sx:max -1
                ]
            ]
        )
    ] .

<http://a.example/I> a sx:ShapeDecl ; sx:shapeExpr [ a sx:ShapeAnd ;
    sx:shapeExprs (
        [ a sx:NodeConstraint ;
            sx:pattern "s........I..$"
        ]
        [ a sx:Shape ;
            sx:expression [ a sx:TripleConstraint ;
                sx:predicate <http://a.example/q>  ;
                sx:valueExpr [ a sx:NodeConstraint ;
                    sx:values (5)
                ]
            ]
        ]
    ) ] .

<http://a.example/J> a sx:ShapeDecl ; sx:shapeExpr [ a sx:ShapeAnd ;
    sx:shapeExprs (
        [ a sx:Shape ; sx:extends ( <http://a.example/H> ) ]
        [ a sx:NodeConstraint ;
            sx:pattern "s.........J.$"
        ]
        [ a sx:Shape ;
            sx:extends (<http://a.example/I>) ;
            sx:expression [ a sx:TripleConstraint ;
                sx:predicate <http://a.example/q>  ;
                sx:valueExpr [ a sx:NodeConstraint ;
                    sx:values (6)
                ]
            ]
        ]
    ) ] .

