module Data.FpML.V53.Standard
( module Data.FpML.V53.Standard
, module Data.FpML.V53.Shared
, module Data.FpML.V53.Asset
) where
import Text.XML.HaXml.Schema.Schema (SchemaType(..),SimpleType(..),Extension(..),Restricts(..))
import Text.XML.HaXml.Schema.Schema as Schema
import Text.XML.HaXml.OneOfN
import qualified Text.XML.HaXml.Schema.PrimitiveTypes as Xsd
import Data.FpML.V53.Shared
import Data.FpML.V53.Asset
elementStandardProduct :: XMLParser StandardProduct
elementStandardProduct = parseSchemaType "standardProduct"
elementToXMLStandardProduct :: StandardProduct -> [Content ()]
elementToXMLStandardProduct = schemaTypeToXML "standardProduct"
data StandardProduct = StandardProduct
{ stdProduct_ID :: Maybe Xsd.ID
, stdProduct_primaryAssetClass :: Maybe AssetClass
, stdProduct_secondaryAssetClass :: [AssetClass]
, stdProduct_productType :: [ProductType]
, stdProduct_productId :: [ProductId]
, stdProduct_notional :: CashflowNotional
, stdProduct_quote :: [BasicQuotation]
}
deriving (Eq,Show)
instance SchemaType StandardProduct where
parseSchemaType s = do
(pos,e) <- posnElement [s]
a0 <- optional $ getAttribute "id" e pos
commit $ interior e $ return (StandardProduct a0)
`apply` optional (parseSchemaType "primaryAssetClass")
`apply` many (parseSchemaType "secondaryAssetClass")
`apply` many (parseSchemaType "productType")
`apply` many (parseSchemaType "productId")
`apply` parseSchemaType "notional"
`apply` many1 (parseSchemaType "quote")
schemaTypeToXML s x@StandardProduct{} =
toXMLElement s [ maybe [] (toXMLAttribute "id") $ stdProduct_ID x
]
[ maybe [] (schemaTypeToXML "primaryAssetClass") $ stdProduct_primaryAssetClass x
, concatMap (schemaTypeToXML "secondaryAssetClass") $ stdProduct_secondaryAssetClass x
, concatMap (schemaTypeToXML "productType") $ stdProduct_productType x
, concatMap (schemaTypeToXML "productId") $ stdProduct_productId x
, schemaTypeToXML "notional" $ stdProduct_notional x
, concatMap (schemaTypeToXML "quote") $ stdProduct_quote x
]
instance Extension StandardProduct Product where
supertype v = Product_StandardProduct v