Am Dienstag, 27. November 2007 schrieb Dragos Ionita: > I'm having a problem with table_to_xmlschema, for VARCHAR fields the > function returns: > > <xsd:simpleType name="VARCHAR"> > </xsd:simpleType> > > And parsers don't seem to like this: > > Invalid XML schema: 'Further elements required under element > <xsd:simpleType>.' > > The simpleType should have a child element. Is this a bug or am I missing > something?
Oh yes, I didn't consider the XML Schema specification well enough. Please try the attached patch. Do you know of an XML Schema checker that we could use to check this? -- Peter Eisentraut http://developer.postgresql.org/~petere/
Index: src/backend/utils/adt/xml.c =================================================================== RCS file: /cvsroot/pgsql/src/backend/utils/adt/xml.c,v retrieving revision 1.62 diff -u -3 -p -r1.62 xml.c --- src/backend/utils/adt/xml.c 27 Nov 2007 18:13:01 -0000 1.62 +++ src/backend/utils/adt/xml.c 28 Nov 2007 10:48:21 -0000 @@ -2984,12 +2984,14 @@ map_sql_type_to_xmlschema_type(Oid typeo case BPCHAROID: case VARCHAROID: case TEXTOID: + appendStringInfo(&result, + " <xsd:restriction base=\"xsd:string\">\n"); if (typmod != -1) appendStringInfo(&result, - " <xsd:restriction base=\"xsd:string\">\n" - " <xsd:maxLength value=\"%d\"/>\n" - " </xsd:restriction>\n", + " <xsd:maxLength value=\"%d\"/>\n", typmod - VARHDRSZ); + appendStringInfo(&result, + " </xsd:restriction>\n"); break; case BYTEAOID: @@ -2997,6 +2999,7 @@ map_sql_type_to_xmlschema_type(Oid typeo " <xsd:restriction base=\"xsd:%s\">\n" " </xsd:restriction>\n", xmlbinary == XMLBINARY_BASE64 ? "base64Binary" : "hexBinary"); + break; case NUMERICOID: if (typmod != -1)
---------------------------(end of broadcast)--------------------------- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match