diff --git a/Swish/RDF/GraphClass.hs b/Swish/RDF/GraphClass.hs
--- a/Swish/RDF/GraphClass.hs
+++ b/Swish/RDF/GraphClass.hs
@@ -36,14 +36,17 @@
 
 import Data.List (union, (\\))
 
--- | Labelled Directed Graph class
---
---  Minimum required implementation:  `setArcs`, `getArcs` and `containedIn`.
---
 --  NOTE:  I wanted to declare this as a subclass of Functor, but
 --  the constraint on the label type seems to prevent that.
 --  So I've just declared specific instances to be Functors.
 --
+
+{-|
+Labelled Directed Graph class
+
+Minimum required implementation:  `setArcs`, `getArcs` and `containedIn`
+(although @containedIn@ may be removed as it is currently unused).
+-}
 class (Eq (lg lb), Eq lb ) => LDGraph lg lb
     where
     --  empty graph
@@ -84,6 +87,8 @@
     nodes g     = foldl union [] (map arcNodes (getArcs g))
     
     -- | Test for graph containment in another.
+    --
+    -- At present this is unused and may be removed in a future release.
     containedIn :: lg lb -> lg lb -> Bool 
     
     -- | Update the arcs in a graph using a supplied function.
@@ -98,9 +103,13 @@
   This means adding the emptyGr function to the interface
 -}
 
--- |Function to replace arcs in a graph with a given list of arcs
+-- |Function to replace arcs in a graph with a given list of arcs.
+--
+-- This is identical to @flip setArcs@ and so may be removed.
+--    
 replaceArcs :: (LDGraph lg lb) => lg lb -> [Arc lb] -> lg lb
-replaceArcs gr as = update (const as) gr
+replaceArcs = flip setArcs
+-- replaceArcs gr as = update (const as) gr
 
 -- | Label class
 --
@@ -135,15 +144,22 @@
 
 -- | Arc type
 
-data Arc lb = Arc { asubj, apred, aobj :: lb }
-    deriving (Eq, Functor, F.Foldable, T.Traversable)
+data Arc lb = Arc 
+              { asubj :: lb  -- ^ The subject of the arc.
+              , apred :: lb  -- ^ The predicate (property) of the arc.
+              , aobj :: lb   -- ^ The object of the arc.
+              }
+            deriving (Eq, Functor, F.Foldable, T.Traversable)
 
+-- | Return the subject of the arc.
 arcSubj :: Arc lb -> lb
 arcSubj = asubj
 
+-- | Return the predicate (property) of the arc.
 arcPred :: Arc lb -> lb
 arcPred = apred
 
+-- | Return the object of the arc.
 arcObj :: Arc lb -> lb
 arcObj = aobj
 
@@ -154,10 +170,11 @@
        -> Arc lb
 arc = Arc
 
+-- | Convert an Arc into a tuple.
 arcToTriple :: Arc lb -> (lb,lb,lb)
 arcToTriple (Arc s p o) = (s, p, o)
--- arcToTriple a = (asubj a,apred a,aobj a)
 
+-- | Create an Arc from a tuple.
 arcFromTriple :: (lb,lb,lb) -> Arc lb
 arcFromTriple (s,p,o) = Arc s p o
 
@@ -182,6 +199,7 @@
     show (Arc lb1 lb2 lb3) =
         "("++ show lb1 ++","++ show lb2 ++","++ show lb3 ++")"
 
+-- | Identify arcs.
 type Selector lb = Arc lb -> Bool
 
 hasLabel :: (Eq lb) => lb -> Arc lb -> Bool
diff --git a/Swish/RDF/RDFGraph.hs b/Swish/RDF/RDFGraph.hs
--- a/Swish/RDF/RDFGraph.hs
+++ b/Swish/RDF/RDFGraph.hs
@@ -97,7 +97,8 @@
 import Swish.Utils.LookupMap
     ( LookupMap(..), LookupEntryClass(..)
     , listLookupMap
-    , mapFind, mapFindMaybe, mapReplaceOrAdd, mapVals, mapKeys )
+    , mapFind, mapFindMaybe, mapReplaceOrAdd, mapAddIfNew
+    , mapVals, mapKeys )
 
 import qualified Data.Foldable as F
 import qualified Data.Traversable as T
@@ -109,7 +110,7 @@
 
 import Data.Monoid (Monoid(..))
 import Data.Char (isDigit, toLower)
-import Data.List (intersect, union, findIndices)
+import Data.List (intersect, union, findIndices, foldl')
 import Data.Ord (comparing)
 import Data.String (IsString(..))
 import Data.Time (UTCTime, Day, ParseTime, parseTime, formatTime)
@@ -260,9 +261,11 @@
 
 -- instances for type conversion to/from RDFLabel
   
+-- | This is just `id`.
 instance ToRDFLabel RDFLabel where
   toRDFLabel = id
   
+-- | This is just `Just . id`.  
 instance FromRDFLabel RDFLabel where
   fromRDFLabel = Just . id
   
@@ -283,30 +286,36 @@
 tLabel :: (Show a) => ScopedName -> (String -> String) -> a -> RDFLabel                      
 tLabel dtype conv = flip Lit (Just dtype) . conv . show                      
 
+-- | The character is converted to an untyped literal of length one.
 instance ToRDFLabel Char where
   toRDFLabel = flip Lit Nothing . (:[])
 
+-- | The label must be an untyped literal containing a single character.
 instance FromRDFLabel Char where
   fromRDFLabel (Lit [c] Nothing) = Just c
   fromRDFLabel _ = Nothing
 
+-- | Strings are converted to untyped literals.
 instance ToRDFLabel String where
   toRDFLabel = flip Lit Nothing
 
+-- | Only untyped literals are converted to strings.
 instance FromRDFLabel String where
   fromRDFLabel (Lit xs Nothing) = Just xs
   fromRDFLabel _ = Nothing
 
--- | Converts to a literal with a @xsd:boolean@ datatype.
-instance ToRDFLabel Bool where
-  toRDFLabel b = Lit (if b then "true" else "false") (Just xsd_boolean)
-                                                 
 strToBool :: String -> Maybe Bool
 strToBool s | s `elem` ["1", "true"]  = Just True
             | s `elem` ["0", "false"] = Just False
             | otherwise               = Nothing
 
--- | Converts from a literal with a @xsd:boolean@ datatype.
+-- | Converts to a literal with a @xsd:boolean@ datatype.
+instance ToRDFLabel Bool where
+  toRDFLabel b = Lit (if b then "true" else "false") (Just xsd_boolean)
+                                                 
+-- | Converts from a literal with a @xsd:boolean@ datatype. The
+-- literal can be any of the supported XSD forms - e.g. \"0\" or
+-- \"true\".
 instance FromRDFLabel Bool where
   fromRDFLabel = fLabel strToBool xsd_boolean
 
@@ -341,15 +350,21 @@
 strToDouble :: String -> Maybe Double      
 strToDouble = strToRealFloat Just
 
+-- | Converts to a literal with a @xsd:float@ datatype.
 instance ToRDFLabel Float where
   toRDFLabel = fromRealFloat xsd_float
   
+-- | Converts from a literal with a @xsd:float@ datatype.
+-- The conversion will fail if the value is outside the valid range of
+-- a Haskell `Float`.
 instance FromRDFLabel Float where
   fromRDFLabel = fLabel strToFloat xsd_float
                  
+-- | Converts to a literal with a @xsd:double@ datatype.
 instance ToRDFLabel Double where
   toRDFLabel = fromRealFloat xsd_double
   
+-- | Converts from a literal with a @xsd:double@ datatype.
 instance FromRDFLabel Double where
   fromRDFLabel = fLabel strToDouble xsd_double
   
@@ -358,6 +373,8 @@
 --         
 -- TODO: add in support for Int8/..., Word8/...  
 --  
+
+-- | Converts to a literal with a @xsd:integer@ datatype.
 instance ToRDFLabel Int where
   toRDFLabel = tLabel xsd_integer id
 
@@ -380,12 +397,17 @@
   
   in maybeRead s >>= conv
 
+-- | Converts from a literal with a @xsd:integer@ datatype.
+-- The conversion will fail if the value is outside the valid range of
+-- a Haskell `Int`.
 instance FromRDFLabel Int where
   fromRDFLabel = fLabel strToInt xsd_integer
 
+-- | Converts to a literal with a @xsd:integer@ datatype.
 instance ToRDFLabel Integer where
   toRDFLabel = tLabel xsd_integer id
 
+-- | Converts from a literal with a @xsd:integer@ datatype.
 instance FromRDFLabel Integer where
   fromRDFLabel = fLabel maybeRead xsd_integer
 
@@ -432,42 +454,52 @@
 toDayFormat :: String -> Maybe Day
 toDayFormat = toTimeFormat "%F"
     
+-- | Converts to a literal with a @xsd:datetime@ datatype.
 instance ToRDFLabel UTCTime where
   toRDFLabel = flip Lit (Just xsd_dateTime) . fromUTCFormat
   
+-- | Converts from a literal with a @xsd:datetime@ datatype.
 instance FromRDFLabel UTCTime where
   fromRDFLabel = fLabel toUTCFormat xsd_dateTime
   
+-- | Converts to a literal with a @xsd:date@ datatype.
 instance ToRDFLabel Day where
   toRDFLabel = flip Lit (Just xsd_date) . fromDayFormat
 
+-- | Converts from a literal with a @xsd:date@ datatype.
 instance FromRDFLabel Day where
   fromRDFLabel = fLabel toDayFormat xsd_date
   
+-- | Converts to a Resource.
 instance ToRDFLabel ScopedName where  
   toRDFLabel = Res
 
+-- | Converts from a Resource.
 instance FromRDFLabel ScopedName where
   fromRDFLabel (Res sn) = Just sn
   fromRDFLabel _        = Nothing
   
+-- | Converts to a Resource.
 instance ToRDFLabel QName where  
   toRDFLabel = Res . makeQNameScopedName
   
+-- | Converts from a Resource.
 instance FromRDFLabel QName where
   fromRDFLabel (Res sn) = Just $ getQName sn
   fromRDFLabel _        = Nothing
   
+-- | Converts to a Resource.
 instance ToRDFLabel URI where  
   toRDFLabel u = Res $ makeUriScopedName $ uriToString id u ""
   
+-- | Converts from a Resource.
 instance FromRDFLabel URI where
   fromRDFLabel (Res sn) = parseURI $ getScopedNameURI sn
   fromRDFLabel _        = Nothing
 
 -- | Get the canonical string for RDF label.
 --
---  Used for hashing, so that equivalent labels always return
+--  This is used for hashing, so that equivalent labels always return
 --  the same hash value.
 --    
 showCanon :: RDFLabel -> String
@@ -488,8 +520,8 @@
   res_rdfd_maxCardinality, res_owl_sameAs, res_log_implies
   :: RDFLabel
 
-res_rdf_type                = Res rdf_type
-res_rdf_first               = Res rdf_first
+res_rdf_type                = Res rdf_type 
+res_rdf_first               = Res rdf_first 
 res_rdf_rest                = Res rdf_rest
 res_rdf_nil                 = Res rdf_nil
 res_rdfs_member             = Res rdfs_member
@@ -585,7 +617,7 @@
 
 -- | Convert 3 RDF labels to a RDF triple.
 --
---   See also `arcFromTriple`.
+--   See also `Swish.RDF.GraphClass.arcFromTriple`.
 toRDFTriple :: 
   (ToRDFLabel s, ToRDFLabel p, ToRDFLabel o) 
   => s -- ^ Subject 
@@ -597,7 +629,7 @@
 
 -- | Extract the contents of a RDF triple.
 --
---   See also `arcToTriple`.
+--   See also `Swish.RDF.GraphClass.arcToTriple`.
 fromRDFTriple :: 
   (FromRDFLabel s, FromRDFLabel p, FromRDFLabel o) 
   => RDFTriple 
@@ -619,14 +651,15 @@
 
 type RevNamespaceMap = LookupMap RevNamespace
 
+-- | Create an emoty namespace map.
 emptyNamespaceMap :: NamespaceMap
 emptyNamespaceMap = LookupMap []
 
 -- | Graph formula entry
 
 data LookupFormula lb gr = Formula
-    { formLabel :: lb
-    , formGraph :: gr
+    { formLabel :: lb -- ^ The label for the formula
+    , formGraph :: gr -- ^ The contents of the formula
     }
 
 instance (Eq lb, Eq gr) => Eq (LookupFormula lb gr) where
@@ -647,6 +680,7 @@
 
 type FormulaMap lb = LookupMap (LookupFormula lb (NSGraph lb))
 
+-- | Create an empty formula map.
 emptyFormulaMap :: FormulaMap RDFLabel
 emptyFormulaMap = LookupMap []
 
@@ -690,14 +724,29 @@
     
 -}
 
--- | Memory-based graph with namespaces and subgraphs
+{-|
 
+Memory-based graph with namespaces and subgraphs.
+
+The primary means for adding arcs to an existing graph
+are: 
+
+ - `setArcs` from the `LDGraph` instance, which replaces the 
+    existing set of arcs and does not change the namespace 
+    map.
+
+ - `addArc` which checks that the arc is unknown before
+    adding it but does not change the namespace map or
+    re-label any blank nodes in the arc.
+
+-}
 data NSGraph lb = NSGraph
-    { namespaces :: NamespaceMap
-    , formulae   :: FormulaMap lb
-    , statements :: [Arc lb]
+    { namespaces :: NamespaceMap    -- ^ the namespaces to use
+    , formulae   :: FormulaMap lb   -- ^ any associated formulae (a.k.a. sub- or named- graps)
+    , statements :: [Arc lb]        -- ^ the statements in the graph
     }
 
+-- | Retrieve the namespace map in the graph.
 getNamespaces :: NSGraph lb -> NamespaceMap
 getNamespaces = namespaces
 
@@ -705,6 +754,7 @@
 setNamespaces      :: NamespaceMap -> NSGraph lb -> NSGraph lb
 setNamespaces ns g = g { namespaces=ns }
 
+-- | Retrieve the formulae in the graph.
 getFormulae :: NSGraph lb -> FormulaMap lb
 getFormulae = formulae
 
@@ -712,6 +762,7 @@
 setFormulae      :: FormulaMap lb -> NSGraph lb -> NSGraph lb
 setFormulae fs g = g { formulae=fs }
 
+-- | Find a formula in the graph, if it exists.
 getFormula     :: (Label lb) => NSGraph lb -> lb -> Maybe (NSGraph lb)
 getFormula g l = mapFindMaybe l (formulae g)
 
@@ -728,8 +779,11 @@
     setArcs as g = g { statements=as }
     containedIn = error "containedIn for LDGraph NSGraph lb is undefined!" -- TODO: should there be one defined?
 
--- | Add an arc to the graph. It does not check for duplicates
--- nor does it relabel any blank nodes in the input arc.
+{-|
+Add an arc to the graph. It does not relabel any blank nodes in the input arc,
+nor does it change the namespace map, 
+but it does ensure that the arc is unknown before adding it.
+-}
 addArc :: (Label lb) => Arc lb -> NSGraph lb -> NSGraph lb
 addArc ar gr = gr { statements=addSetElem ar (statements gr) }
 
@@ -802,9 +856,13 @@
         add gr1 (remapLabels dupbn allbn id gr2)
 
 -- |Return list of all labels (including properties) in the graph
---  satisfying a supplied filter predicate.
+--  satisfying a supplied filter predicate. This routine
+--  includes the labels in any formulae.
 allLabels :: (Label lb) => (lb -> Bool) -> NSGraph lb -> [lb]
-allLabels p gr = filter p (unionNodes p (formulaNodes p gr) (labels gr) )
+allLabels p gr = filter p (unionNodes p (formulaNodes p gr) (labels gr) ) 
+                 
+{- TODO: is the leading 'filter p' needed in allLabels?
+-}
 
 -- |Return list of all subjects and objects in the graph
 --  satisfying a supplied filter predicate.
@@ -827,7 +885,7 @@
 unionNodes :: (Label lb) => (lb -> Bool) -> [lb] -> [lb] -> [lb]
 unionNodes p ls1 ls2 = ls1 `union` filter p ls2
 
--- |Remap selected nodes in graph:
+-- |Remap selected nodes in graph.
 --
 --  This is the node renaming operation that prevents graph-scoped
 --  variable nodes from being merged when two graphs are merged.
@@ -921,10 +979,33 @@
 type RDFGraph = NSGraph RDFLabel
 
 -- |Create a new RDF graph from a supplied list of arcs
-toRDFGraph :: [Arc RDFLabel] -> RDFGraph
-toRDFGraph arcs = emptyRDFGraph { statements = arcs }
+--
+-- This version will attempt to fill up the namespace map
+-- of the graph based on the input labels (including datatypes
+-- on literals). For faster
+-- creation of a graph you can use:
+--
+-- > emptyRDFGraph { statements = arcs }
+--
+-- which is how this routine was defined in version @0.3.1.1@
+-- and earlier.
+--
+toRDFGraph :: [RDFTriple] -> RDFGraph
+-- toRDFGraph arcs = emptyRDFGraph { statements = arcs }
+toRDFGraph arcs = 
+  let lbls = concatMap (\(Arc s p o) -> [s,p,o]) arcs
+      ns1  = map (snScope . getScopedName) (filter isUri lbls)
+      ns2  = map (snScope . getDataType) (filter isTypedLiteral lbls)
+      getDataType (Lit _ (Just dt)) = dt
+      getDataType _ = nullScopedName -- should not happen
+      nsmap = foldl' mapAddIfNew emptyNamespaceMap (ns1++ns2)
+  in mempty { namespaces = nsmap, statements = arcs }
 
 -- |Create a new, empty RDF graph.
+--
+-- This uses `mempty` from the `Monoid` instance
+-- of `NSGraph`.
+--
 emptyRDFGraph :: RDFGraph
 emptyRDFGraph = mempty 
 
@@ -935,7 +1016,7 @@
 --  [[[TODO:  I think this may be redundant - the default graph
 --  class has an update method which accepts a function to update
 --  the arcs, not touching other parts of the graph value.]]]
-updateRDFGraph :: RDFGraph -> [Arc RDFLabel] -> RDFGraph
+updateRDFGraph :: RDFGraph -> [RDFTriple] -> RDFGraph
 updateRDFGraph gr as = gr { statements=as }
 -}
 
diff --git a/swish.cabal b/swish.cabal
--- a/swish.cabal
+++ b/swish.cabal
@@ -1,5 +1,5 @@
 Name:               swish
-Version:            0.3.1.1
+Version:            0.3.1.2
 Stability:          experimental
 License:            LGPL
 License-file:       LICENSE 
@@ -45,6 +45,10 @@
   * Complete, ready-to-run, command-line and script-driven programs.
   .
   Major Changes:
+  .
+  [Version 0.3.1.2] 'Swish.RDF.RDFGraph.toRDFGraph' now sets up the
+  namespace map of the graph based on the input labels (previously it
+  left the map empty).
   .
   [Version 0.3.1.1] Bug fixes for N3 format: strings ending in a 
   double quote character are now written out correctly and
diff --git a/tests/N3FormatterTest.hs b/tests/N3FormatterTest.hs
--- a/tests/N3FormatterTest.hs
+++ b/tests/N3FormatterTest.hs
@@ -38,11 +38,12 @@
 
 import Swish.Utils.LookupMap
     ( LookupMap(..)
-    , emptyLookupMap, makeLookupMap, mapAdd )
+    , emptyLookupMap
+    , makeLookupMap)
 
 import Swish.RDF.GraphClass (Arc, arc)
 
-import Swish.RDF.Vocabulary (langName)
+import Swish.RDF.Vocabulary (langName, namespaceRDF, namespaceXSD)
 
 import Data.Monoid (Monoid(..))
 import Data.String (IsString(..))
@@ -166,7 +167,7 @@
     ]
 
 g1np :: RDFGraph
-g1np = toRDFGraph [t01]
+g1np = emptyRDFGraph { namespaces = makeLookupMap [base1], statements = [t01] }
 
 toGraph :: [Arc RDFLabel] -> RDFGraph
 toGraph arcs = (toRDFGraph arcs) {namespaces = nslist}
@@ -212,7 +213,7 @@
 ----
 
 g2, g3, g4, g5, g6, g7 :: RDFGraph
-g2 = toGraph [t01,t02,t03]
+g2 = toRDFGraph [t01,t02,t03]
 g3 = toGraph [t01,t04]
 g4 = toGraph [t01,t05]
 g5 = toGraph [t01,t02,t03,t04,t05]
@@ -611,24 +612,24 @@
 
 graph_b1, graph_b1rev, graph_b2, graph_b2rev, graph_b3, 
   graph_b4, graph_b5 :: RDFGraph
-graph_b1    = toGraph [arc s1 p1 b1]
-graph_b1rev = toGraph [arc b1 p1 o1]
-graph_b2    = toGraph [arc s1 p1 b1,
-                       arc b1 p2 l1,
-                       arc b1 o2 o3]
-graph_b2rev = toGraph [arc b1 p2 l1,
-                       arc b1 o2 o3,
-                       arc b1 p1 o1]
-graph_b3    = toGraph [arc s1 p1 b1,
-                       arc b1 p2 l2,
-                       arc b1 o2 o3,
-                       arc s1 p2 b2,
-                       arc s2 p2 o2]
-graph_b4    = toGraph [arc b1 res_rdf_type o1,
-                       arc b2 res_rdf_type o2]
-graph_b5    = toGraph [arc b1 res_rdf_type o1,
-                       arc b2 p2 o2,
-                       arc b3 res_rdf_type o3]
+graph_b1    = toRDFGraph [arc s1 p1 b1]
+graph_b1rev = toRDFGraph [arc b1 p1 o1]
+graph_b2    = toRDFGraph [arc s1 p1 b1,
+                          arc b1 p2 l1,
+                          arc b1 o2 o3]
+graph_b2rev = toRDFGraph [arc b1 p2 l1,
+                          arc b1 o2 o3,
+                          arc b1 p1 o1]
+graph_b3    = toRDFGraph [arc s1 p1 b1,
+                          arc b1 p2 l2,
+                          arc b1 o2 o3,
+                          arc s1 p2 b2,
+                          arc s2 p2 o2]
+graph_b4    = toRDFGraph [arc b1 res_rdf_type o1,
+                          arc b2 res_rdf_type o2]
+graph_b5    = toRDFGraph [arc b1 res_rdf_type o1,
+                          arc b2 p2 o2,
+                          arc b3 res_rdf_type o3]
 
 -- datatype/literal graphs
 
@@ -637,18 +638,23 @@
 graph_l2 = toGraph [arc s1 p1 lfoobar]
 graph_l3 = 
   let tf a = toRDFTriple s1 p1 a
-      gtmp = toGraph [ tf True
-                     , tf (12::Int)
-                       
-                       -- so, issue over comparing -2.304e-108 and value read in from string
-                       -- due to comparing a ScopedName instance built from a RDFLabel
-                       -- as the hash used in the comparison is based on the Show value
-                       -- but then why isn't this a problem for Float
-                       
-                     , tf ((-2.304e-108)::Double)
-                     , tf (23.4::Float)  
-                     ]
+      arcs = [ tf True
+             , tf (12::Int)
+               
+               -- so, issue over comparing -2.304e-108 and value read in from string
+               -- due to comparing a ScopedName instance built from a RDFLabel
+               -- as the hash used in the comparison is based on the Show value
+               -- but then why isn't this a problem for Float
+               
+             , tf ((-2.304e-108)::Double)
+             , tf (23.4::Float)  
+             ]
+  {-             
+      gtmp = toRDFGraph arcs
   in gtmp { namespaces = mapAdd (namespaces gtmp) (Namespace "xsd" "http://www.w3.org/2001/XMLSchema#") }
+  -}
+  in toRDFGraph arcs
+   
 graph_l4 = toGraph [ toRDFTriple s1 p1 "A string with \"quotes\""
                    , toRDFTriple s2 p2 (Lit "A typed string with \"quotes\"" (Just (fromString "urn:a#b")))
                    ]                    
@@ -679,14 +685,36 @@
     where
       (res,nmap,ngen,trc) = formatGraphDiag gr
 
+mkPrefix :: String -> Namespace -> String
+mkPrefix lbl ns = "@prefix " ++ lbl ++ ": <" ++ nsURI ns ++ "> .\n"
+
+prefixList :: [String]
+prefixList = 
+  [ mkPrefix "base1" base1
+  , mkPrefix "base2" base2
+  , mkPrefix "base3" base3
+  , mkPrefix "base4" base4
+  , mkPrefix "rdf"   namespaceRDF
+  , mkPrefix "xsd"   namespaceXSD
+  ]
+
 commonPrefixes :: String
-commonPrefixes =
-    "@prefix base1: <" ++ nsURI base1 ++ "> .\n" ++
-    "@prefix base2: <" ++ nsURI base2 ++ "> .\n" ++
-    "@prefix base3: <" ++ nsURI base3 ++ "> .\n" ++
-    "@prefix base4: <" ++ nsURI base4 ++ "> .\n"
+commonPrefixes = commonPrefixesN [0..3]
 
+commonPrefixesN :: [Int] -> String
+commonPrefixesN = concatMap (prefixList !!)
+
+commonPrefixes21 :: String
+commonPrefixes21 = concatMap (prefixList !!) [1, 0]
+
+commonPrefixes321 :: String
+commonPrefixes321 = concatMap (prefixList !!) [2, 1, 0]
+
+commonPrefixes132 :: String
+commonPrefixes132 = concatMap (prefixList !!) [0, 2, 1]
+
 --  Single statement using <uri> form
+
 simpleN3Graph_g1_01 :: String
 simpleN3Graph_g1_01 =
     "<http://id.ninebynine.org/wip/2003/test/graph1/node#s1> " ++
@@ -824,40 +852,40 @@
 
 simpleN3Graph_b1 :: String
 simpleN3Graph_b1 =
-    commonPrefixes ++
+    head prefixList ++
     "base1:s1 base1:p1 [] .\n"
 
 simpleN3Graph_b1rev :: String
 simpleN3Graph_b1rev =
-    commonPrefixes ++
+    head prefixList ++
     "[\n base1:p1 base1:o1\n] .\n"
 
 simpleN3Graph_b2 :: String
 simpleN3Graph_b2 =
-    commonPrefixes ++
+    commonPrefixesN [2,1,0] ++
     "base1:s1 base1:p1 [\n base2:o2 base3:o3 ;\n base2:p2 \"l1\"\n] .\n"
 
 simpleN3Graph_b2rev :: String
 simpleN3Graph_b2rev =
-    commonPrefixes ++
+    commonPrefixesN [0,2,1] ++
     "[\n base1:p1 base1:o1 ;\n base2:o2 base3:o3 ;\n base2:p2 \"l1\"\n] .\n"
 
 simpleN3Graph_b3 :: String
 simpleN3Graph_b3 =
-    commonPrefixes ++
+    commonPrefixesN [2,1,0] ++
     "base1:s1 base1:p1 [\n base2:o2 base3:o3 ;\n base2:p2 \"\"\"" ++ l2txt ++ "\"\"\"\n] ;\n" ++
     "         base2:p2 [] .\n" ++
     "base2:s2 base2:p2 base2:o2 .\n"
 
 simpleN3Graph_b4 :: String
 simpleN3Graph_b4 =
-  commonPrefixes ++
+  commonPrefixesN [1,0,4] ++
   "[\n a base1:o1\n] .\n" ++ 
   "[\n a base2:o2\n] .\n"
 
 simpleN3Graph_b5 :: String
 simpleN3Graph_b5 =
-  commonPrefixes ++
+  commonPrefixesN [2,1,0,4] ++
   "[\n a base1:o1\n] .\n" ++ 
   "[\n base2:p2 base2:o2\n] .\n" ++
   "[\n a base3:o3\n] .\n"
@@ -878,8 +906,7 @@
   
 simpleN3Graph_l3 :: String
 simpleN3Graph_l3 =
-  "@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .\n" ++ 
-  commonPrefixes ++ 
+  commonPrefixesN [5,0] ++
   "\n" ++ -- TODO: why do we need this newline?
   "base1:s1 base1:p1 \"2.34E1\"^^xsd:float,\n" ++ 
   "                  -2.304e-108,\n" ++ 
@@ -893,8 +920,8 @@
 
 trivialTestSuite :: Test
 trivialTestSuite = TestList
- [ formatTest "trivialTest01" g1np simpleN3Graph_g1_01
- , formatTest "trivialTest02" g1   simpleN3Graph_g1_02
+ [ -- formatTest "trivialTest01" g1np simpleN3Graph_g1_01  - no longer valid as now add in a prefix/namespace declaration
+   formatTest "trivialTest02" g1   simpleN3Graph_g1_02
  , formatTest "trivialTest03" g1b1 simpleN3Graph_g1_03
  , formatTest "trivialTest04" g1a1 simpleN3Graph_g1_04
  , formatTest "trivialTest05" g1l1 simpleN3Graph_g1_05
