[cduce-users] Problems using print_xml

Alain Frisch Alain.Frisch at inria.fr
Tue May 16 17:06:03 CEST 2006


pierluigi wrote:
> Hello, I'm actually encountering a tedious problem using print_xml
> function.
> 
> type block = <h1>[String]
> test = <h1>[ "Other article 2005" ]
> 
> 
> When I go to apply print_xml to test, I got this error
> 
> print_xml test;;
> Uncaught CDuce exception: [ `Invalid_argument 'print_xml' ]
> 
> 
> but if I apply print_xml to the value of test directly, it works well

In the beginning, print_xml was supposed to print only values which
correspond to parsed XML documents. Such values should be of the type:

type T = <(Atom) (Record)>[ (T|Char)* ]

(with the additional constraint that attribute values must be strings).

Your value is not in this type, unlike the following one:

  <h1>[ 'Other article' ]

(Note the subtle difference: these are simple quotes.)

At some point, some support was added to help print XML document after
they have been validated against an XML Schema. That's why you can
do "print_xml <a>[ 1 2 ]", and it is also why strings (and not only
chars) are now accepted as children of XML elements. There was a missing
case in this extended pretty-printer; as a consequence, only strings
which were internally encoded in UTF-8 where accepted.

This bug is now fixed in the CVS. Thanks for reporting it.

That said, you probably want to write <h1>[ 'Other article' ]
instead of <h1>[ "Other article" ]. The printer for validated values is
some kind of a hack. I would advise people not to rely on it.

-- Alain



More information about the Cduce-users mailing list