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/#A> a sx:ShapeDecl ; sx:shapeExpr [ a sx:Shape ; sx:expression [ a sx:EachOf;
    sx:expressions (
        [ a sx:TripleConstraint ;
            sx:predicate <http://a.example/p> ;
            sx:min 2;
            sx:max 2
        ]
        [ a sx:TripleConstraint ;
            sx:predicate <http://a.example/q>  ;
            sx:valueExpr [ a sx:NodeConstraint ;
                sx:values (3)
            ]
        ]
    )
] ] .

<http://a.example/#B> a sx:ShapeDecl ; sx:shapeExpr [ a sx:ShapeAnd ;
    sx:shapeExprs (
        <http://a.example/#A>
        [ a sx:Shape ;
            sx:expression [ a sx:EachOf;
                sx:expressions (
                    [ a sx:TripleConstraint ;
                        sx:predicate <http://a.example/p> ;
                        sx:min 1;
                        sx:max 3
                    ]
                    [ a sx:TripleConstraint ;
                        sx:predicate <http://a.example/q> ;
                        sx:min 1;
                        sx:max 3
                    ]
                )
            ]
        ]
    ) ] .

<http://a.example/#C> a sx:ShapeDecl ; sx:shapeExpr [ a sx:Shape ;
    sx:extends (<http://a.example/#B>)  ;
    sx:expression [ a sx:TripleConstraint ;
        sx:predicate <http://a.example/p>
    ] ] .

