Hi,

I do not know whether there is already written routines for this task,
but I have written some util functions to help debugging xml values.
It strips html tags and newlines from already constructed xml data.

Adam, what do you think of this? Is it valuable to include in the distribution?

- Gergely

$ cat debugUtil.ur
fun deleteHtml s =
    let
        val chars = String.length s - 1

        fun delete i acc =
            if (i > chars)
               then acc
               else
                    let
                        val nextChar = String.sub s i
                     in
                        if nextChar = #"<"
                           then inTag (i+1) acc
                           else delete (i+1) (acc ^ String.str nextChar)
                    end

        and inTag i acc =
            if (i > chars)
               then acc
               else
                    let
                        val nextChar = String.sub s i
                     in
                        if nextChar = #">"
                           then delete (i+1) acc
                           else inTag (i+1) acc
                    end
     in
        delete 0 ""
    end

fun deleteChar ch s =
    let
        val chars = String.length s - 1

        fun delete i acc =
            if (i > chars)
               then acc
               else
                    let
                        val nextChar = String.sub s i
                     in
                        if nextChar = ch
                           then delete (i+1) acc
                           else delete (i+1) (acc ^ String.str nextChar)
                    end

     in
        delete 0 ""
    end

fun xmlToString [ ctx ::: {Unit} ] [ use ::: {Type} ] [ bnd ::: {Type}
] ( arg : xml ctx use bnd ) : string =
    deleteChar #"\n" (deleteHtml (show arg))

_______________________________________________
Ur mailing list
[email protected]
http://www.impredicative.com/cgi-bin/mailman/listinfo/ur

Reply via email to