xml-types 0.1.1 → 0.1.2
raw patch · 2 files changed
+18/−4 lines, 2 files
Files
- Data/XML/Types.hs +14/−0
- xml-types.cabal +4/−4
Data/XML/Types.hs view
@@ -60,6 +60,8 @@ ) where import Control.Monad ((>=>)) import Data.Text.Lazy (Text)+import qualified Data.Text.Lazy as T+import Data.String (IsString, fromString) data Document = Document { documentPrologue :: Prologue@@ -111,6 +113,11 @@ | ContentEntity Text deriving (Show, Eq) +-- | The 'Eq' instance for 'Name' ignores prefixes.+--+-- The 'IsString' instance for 'Name' allows entry using Clark notation;+-- see <http://www.jclark.com/xml/xmlns.htm> and+-- <http://infohost.nmt.edu/tcc/help/pubs/pylxml/etree-QName.html> data Name = Name { nameLocalName :: Text , nameNamespace :: Maybe Text@@ -124,6 +131,13 @@ [ nameLocalName x == nameLocalName y , nameNamespace x == nameNamespace y ]++instance IsString Name where+ fromString "" = Name T.empty Nothing Nothing+ fromString full@('{':rest) = case break (== '}') rest of+ (_, "") -> error ("Invalid Clark notation: " ++ show full)+ (ns, local) -> Name (T.pack (drop 1 local)) (Just (T.pack ns)) Nothing+ fromString local = Name (T.pack local) Nothing Nothing class Named a where getName :: a -> Name
xml-types.cabal view
@@ -1,5 +1,5 @@ name: xml-types-version: 0.1.1+version: 0.1.2 synopsis: Basic types for representing XML license: MIT license-file: license.txt@@ -12,11 +12,11 @@ bug-reports: mailto:jmillikin@gmail.com source-repository head- type: darcs- location: http://ianen.org/haskell/xml-types/+ type: bazaar+ location: http://john-millikin.com/software/xml-types/ library- ghc-options: -Wall -fno-warn-unused-do-bind+ ghc-options: -Wall build-depends: base >=3 && < 5