Safe Haskell | None |
---|---|
Language | Haskell2010 |
Parse an XSD into types with the ability to resolve references.
- parseFile :: FilePath -> IO Schema
- loadXsdSchema :: FilePath -> IO Schema
- schemaParser :: XParser m => m Schema
- namespaceSchema :: String -> Schema -> Schema
- qnParser :: Parsec String m QN
- attrParser :: Parsec String m String
- parsec :: Stream s Identity t => Parsec s () a -> s -> a
- qn :: String -> QN
- anySimpleTypeName :: QN
- class Typeable a => Resolvable a where
- refResolve :: Resolvable r => String -> Getting (Map QN r) Schema (Map QN r) -> Schema -> Ref r -> Ref r
- data Ref a
- = Unresolved {
- _unresolved :: !QN
- | Resolved { }
- | Final
- = Unresolved {
- unresolved :: forall a. Traversal' (Ref a) QN
- resolved :: forall a. Traversal' (Ref a) QN
- refvalue :: forall a a. Traversal (Ref a) (Ref a) a a
- data Schema = Schema {
- _simpleTypes :: !(Map QN SimpleType)
- _complexTypes :: !(Map QN ComplexType)
- _groups :: !(Map QN Group)
- _attributeGroups :: !(Map QN AttributeGroup)
- _elements :: !(Map QN Element)
- _attributes :: !(Map QN Attribute)
- simpleTypes :: Lens' Schema (Map QN SimpleType)
- complexTypes :: Lens' Schema (Map QN ComplexType)
- groups :: Lens' Schema (Map QN Group)
- attributeGroups :: Lens' Schema (Map QN AttributeGroup)
- elements :: Lens' Schema (Map QN Element)
- attributes :: Lens' Schema (Map QN Attribute)
- data QN = QN {}
- qLocal :: Lens' QN String
- qPrefix :: Lens' QN (Maybe String)
- data SimpleType
- simpleTypeName :: Lens' SimpleType (Maybe QN)
- simpleTypeRestriction :: Traversal' SimpleType SimpleRestriction
- simpleTypeUnion :: Traversal' SimpleType Union
- simpleTypeDoc :: Lens' SimpleType (Maybe Documentation)
- data Bound a
- data SimpleRestriction = SimpleRestriction {
- _simpleRestrictBase :: !(Ref SimpleType)
- _simpleRestrictEnums :: ![String]
- _simpleRestrictMin :: !(Maybe (Bound String))
- _simpleRestrictMax :: !(Maybe (Bound String))
- _simpleRestrictPattern :: !(Maybe String)
- simpleRestrictBase :: Lens' SimpleRestriction (Ref SimpleType)
- simpleRestrictEnums :: Lens' SimpleRestriction [String]
- simpleRestrictMin :: Lens' SimpleRestriction (Maybe (Bound String))
- simpleRestrictMax :: Lens' SimpleRestriction (Maybe (Bound String))
- simpleRestrictPattern :: Lens' SimpleRestriction (Maybe String)
- data Union = Union {
- _unionMemberTypes :: ![Ref SimpleType]
- _unionSimpleTypes :: ![SimpleType]
- unionMemberTypes :: Lens' Union [Ref SimpleType]
- unionSimpleTypes :: Lens' Union [SimpleType]
- data Attribute
- = AttributeType {
- _attrName :: !QN
- _attrType :: !(Ref SimpleType)
- _attrUse :: !Use
- _attrDefault :: !(Maybe String)
- | AttributeRef { }
- | AttributeSimpleType {
- _attrName :: !QN
- _attrSimpleType :: SimpleType
- = AttributeType {
- attrName :: Traversal' Attribute QN
- attrType :: Traversal' Attribute (Ref SimpleType)
- attrUse :: Traversal' Attribute Use
- attrDefault :: Traversal' Attribute (Maybe String)
- attrRef :: Traversal' Attribute (Ref Attribute)
- attrSimpleType :: Traversal' Attribute SimpleType
- data Use
- data AttributeGroup
- = AttributeGroup { }
- | AttributeGroupRef {
- _attrGroupRef :: !(Ref AttributeGroup)
- attrGroupName :: Traversal' AttributeGroup QN
- attrGroupAttributes :: Traversal' AttributeGroup Attributes
- attrGroupRef :: Traversal' AttributeGroup (Ref AttributeGroup)
- attrGroupDoc :: Traversal' AttributeGroup (Maybe Documentation)
- data Attributes = Attributes {}
- attrsAttributes :: Lens' Attributes [Attribute]
- attrsAttributeGroups :: Lens' Attributes [AttributeGroup]
- data Occurs = Occurs {
- _occursMin :: !(Maybe String)
- _occursMax :: !(Maybe String)
- occursMin :: Lens' Occurs (Maybe String)
- occursMax :: Lens' Occurs (Maybe String)
- data Element
- = ElementType {
- _elementName :: !QN
- _elementType :: !(Ref (Either ComplexType SimpleType))
- _elementOccurs :: !Occurs
- _elementDoc :: Maybe Documentation
- | ElementSimple { }
- | ElementComplex { }
- | ElementRef {
- _elementRef :: !(Ref Element)
- _elementOccurs :: !Occurs
- = ElementType {
- elementName :: Traversal' Element QN
- elementType :: Traversal' Element (Ref (Either ComplexType SimpleType))
- elementOccurs :: Lens' Element Occurs
- elementSimple :: Traversal' Element SimpleType
- elementComplex :: Traversal' Element ComplexType
- elementRef :: Traversal' Element (Ref Element)
- elementDoc :: Traversal' Element (Maybe Documentation)
- data ComplexType
- = ComplexTypeSimple { }
- | ComplexTypeComplex { }
- | ComplexTypeCompositor { }
- complexTypeName :: Lens' ComplexType (Maybe QN)
- complexSimpleContent :: Traversal' ComplexType SimpleContent
- complexComplexContent :: Traversal' ComplexType ComplexContent
- complexCompositor :: Traversal' ComplexType (Maybe Compositor)
- complexAttributes :: Traversal' ComplexType Attributes
- complexTypeDoc :: Lens' ComplexType (Maybe Documentation)
- data SimpleContent = SimpleContentExtension {}
- simpleContentBase :: Lens' SimpleContent (Ref SimpleType)
- simpleContentAttributes :: Lens' SimpleContent Attributes
- data ComplexContent = ComplexContentExtension {}
- complexContentBase :: Lens' ComplexContent (Ref ComplexType)
- complexContentAttributes :: Lens' ComplexContent Attributes
- complexContentCompositor :: Lens' ComplexContent (Maybe Compositor)
- data Compositor
- = CompositorGroup {
- _compGroup :: !Group
- | CompositorChoice {
- _compChoice :: !Choice
- | CompositorSequence { }
- = CompositorGroup {
- compGroup :: Traversal' Compositor Group
- compChoice :: Traversal' Compositor Choice
- compSequence :: Traversal' Compositor Sequence
- data Group
- = GroupChoice {
- _groupName :: !(Maybe QN)
- _groupOccurs :: !Occurs
- _groupChoice :: !Choice
- _groupDoc :: Maybe Documentation
- | GroupSequence {
- _groupName :: !(Maybe QN)
- _groupOccurs :: !Occurs
- _groupSequence :: !Sequence
- _groupDoc :: Maybe Documentation
- | GroupRef {
- _groupRef :: !(Ref Group)
- _groupOccurs :: !Occurs
- = GroupChoice {
- groupName :: Traversal' Group (Maybe QN)
- groupOccurs :: Lens' Group Occurs
- groupChoice :: Traversal' Group Choice
- groupSequence :: Traversal' Group Sequence
- groupRef :: Traversal' Group (Ref Group)
- groupDoc :: Traversal' Group (Maybe Documentation)
- data Particle
- = PartElement {
- _partElement :: !Element
- | PartGroup {
- _partGroup :: !Group
- | PartChoice {
- _partChoice :: !Choice
- | PartSequence { }
- = PartElement {
- partElement :: Traversal' Particle Element
- partGroup :: Traversal' Particle Group
- partChoice :: Traversal' Particle Choice
- partSequence :: Traversal' Particle Sequence
- data Choice = Choice {
- _choiceOccurs :: !Occurs
- _choiceParticles :: ![Particle]
- choiceOccurs :: Lens' Choice Occurs
- choiceParticles :: Lens' Choice [Particle]
- data Sequence = Sequence {
- _sequenceOccurs :: !Occurs
- _sequenceParticles :: ![Particle]
- sequenceOccurs :: Lens' Sequence Occurs
- sequenceParticles :: Lens' Sequence [Particle]
- newtype Documentation = Documentation String
Parsers and utilities
schemaParser :: XParser m => m Schema Source #
Main parser.
namespaceSchema :: String -> Schema -> Schema Source #
Adjust top-level names to have supplied prefix.
anySimpleTypeName :: QN Source #
XML Schema "anySimpleType" (ie, built-ins like string, double etc).
Type References
class Typeable a => Resolvable a where Source #
Resolvable indicates a type has a Ref
member that it can
resolve from a top-level Schema
production.
refResolve :: Resolvable r => String -> Getting (Map QN r) Schema (Map QN r) -> Schema -> Ref r -> Ref r Source #
Schema, QNs, Refs
Model an outward XSD reference.
Unresolved | Just type name. |
| |
Resolved | Type name and resolved value. |
Final | Reserved for built-in types (string, etc) |
Eq a => Eq (Ref a) Source # | |
Data a => Data (Ref a) Source # | |
Show (Ref a) Source # | |
Resolvable (Ref (Either ComplexType SimpleType)) Source # | |
Resolvable (Ref Group) Source # | |
Resolvable (Ref ComplexType) Source # | |
Resolvable (Ref Element) Source # | |
Resolvable (Ref AttributeGroup) Source # | |
Resolvable (Ref Attribute) Source # | |
Resolvable (Ref SimpleType) Source # | |
unresolved :: forall a. Traversal' (Ref a) QN Source #
Schema type, mapping top-level productions to qnames.
Schema | |
|
simpleTypes :: Lens' Schema (Map QN SimpleType) Source #
complexTypes :: Lens' Schema (Map QN ComplexType) Source #
QName type.
Productions
data SimpleType Source #
XSD simpleType production.
simpleTypeName :: Lens' SimpleType (Maybe QN) Source #
Model min/max restrictions.
data SimpleRestriction Source #
simple type restriction production.
SimpleRestriction | |
|
Simple type union production.
Union | |
|
XSD attribute production.
AttributeType | |
| |
AttributeRef | |
AttributeSimpleType | |
|
XSD "use" values.
data AttributeGroup Source #
XSD attribute-group production.
data Attributes Source #
Convenience grouping of attributes and attribute groups, which are always showing up together in xsd.
"occurs-min" and "occurs-max"
Occurs | |
|
XSD element production.
ElementType | |
| |
ElementSimple | |
| |
ElementComplex | |
| |
ElementRef | |
|
elementRef :: Traversal' Element (Ref Element) Source #
data ComplexType Source #
XSD complexType production.
data ComplexContent Source #
complexContent under a complex type. TODO: restrictions
data Compositor Source #
Compositors.
XSD "group" production.
GroupChoice | |
| |
GroupSequence | |
| |
GroupRef | |
|
Particles.
XSD choice
Choice | |
|
XSD sequence.
Sequence | |
|