]> Git — Sourcephile - haskell/symantic-xml.git/blob - test/RelaxNG/Whatever.hs
Rewrite to categorical symantic
[haskell/symantic-xml.git] / test / RelaxNG / Whatever.hs
1 {-# LANGUAGE AllowAmbiguousTypes #-}
2 {-# LANGUAGE DeriveGeneric #-}
3 {-# LANGUAGE FlexibleContexts #-}
4 {-# LANGUAGE NoMonomorphismRestriction #-}
5 {-# LANGUAGE OverloadedStrings #-}
6 {-# LANGUAGE StrictData #-}
7 {-# LANGUAGE TypeApplications #-}
8 {-# OPTIONS_GHC -fno-warn-missing-signatures #-}
9 module RelaxNG.Whatever where
10
11 import Data.Function (($), (.))
12 import Data.Maybe (Maybe(..))
13 import Text.Show (Show)
14 import GHC.Generics (Generic)
15 import qualified Data.Text.Lazy as TL
16
17 import Symantic.XML as XML
18 import Symantic.XML.RelaxNG as RelaxNG
19
20 schema =
21 namespace Nothing xmlns_whatever <.>
22 namespace (Just "xsd") "http://www/w3/org/2001/XMLSchema-datatypes" <.>
23 whatever
24
25 xmlns_whatever :: Namespace
26 xmlns_whatever = "2020/whatever.rnc"
27 elem = element . QName xmlns_whatever
28 attr n = attribute (QName "" n) text
29
30 newtype Whatever
31 = Whatever
32 { whatever_a :: TL.Text
33 } deriving (Generic, Show)
34 whatever =
35 define "root" $
36 adt @Whatever $
37 elem "root" $
38 namespace Nothing xmlns_whatever <.>
39 namespace (Just "whatever") xmlns_whatever <.>
40 attr "a" <.>
41 elem "child" (
42 namespace (Just "what") xmlns_whatever <.>
43 elem "sub-child" (
44 namespace Nothing xmlns_empty <.>
45 empty
46 )
47 )