Dominic,
I use (an extended version of) the CFilter framework to perform namespace, xml:lang and xml:base processing in my revised version of HaXml. Maybe my code [1] might provide some clues for you?
Look for function 'applyNamespaces'.
The function 'buildNamespaces' illustrates my extension to the CFilter framework, which allows an XML document to be transformed into a new document type containing additional information about the XML elements.
'processNamespaces' actually applies the transformations, using function 'docReplaceContent' which is defined in [2]. Maybe this module has the clues you're after?
#g --
[1] http://www.ninebynine.org/Software/HaskellUtils/HaXml-1.12/src/Text/XML/HaXml/Namespace.hs
[2] http://www.ninebynine.org/Software/HaskellUtils/HaXml-1.12/src/Text/XML/HaXml/Traverse.hs
At 15:33 27/11/04 +0000, Dominic Steinitz wrote:
I'd be grateful for some help on using HaXml.
1. I can parse a String into a Document but it's not clear how you operate on it as the combinators all operate on Content. The only function I could find that operated on a Document was "document" in Pretty.
2. I can construct a CFilter but it's not clear how you operate on it. How do I calculate the number of components of an Element? What I would like to do is accept "vname" (with 3 elements) and reject "iname" (with 4 elements). I'd also like to check that the characters in givenName, initial and familyName are in a given range (for example upper case or between ' ' and '~').
Thanks, Dominic.
import Text.XML.HaXml import Text.XML.HaXml.Pretty
xmlName = "<Name><givenName>John</givenName>" ++ "<initial>P</initial>" ++ "<familyName>Smith</familyName>" ++ "</Name>"
d = document $ xmlParse "tmp" xmlName
gn = mkElemAttr "givenName" [] [literal "John"] i = mkElemAttr "initial" [] [literal "P"] fn = mkElemAttr "familyName" [] [literal "Smith"]
validName = mkElemAttr "Name" [] [gn,i,fn] invalidName = mkElemAttr "Name" [] [gn,i,i,fn]
vname = processXmlWith validName iname = processXmlWith invalidName
*Main> d <Name ><givenName >John</givenName ><initial >P</initial ><familyName >Smith</familyName></Name> *Main>
*Main> vname <?xml version='1.0'?> <Name ><givenName >John</givenName ><initial >P</initial ><familyName >Smith</familyName></Name> *Main>
_______________________________________________ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
------------ Graham Klyne For email: http://www.ninebynine.org/#Contact
_______________________________________________ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell