[gdal-dev] GDAL GML driver and .xsd schema mapping

janhec jan.heckman at gmail.com
Sat Dec 15 10:28:06 PST 2012


janhec wrote
> I had to use the debugger to discover that parsexsd.cpp breaks off when an
> attribute has no explicit type assigned to it. I seem to remember that
> there is a default (xsd:string) and suggest implementing this in the xsd
> parser. Line 264 (1.9.1) could be:
> if (pszType == NULL) pszType = "xsd:string";
> if (pszType != NULL)
> {
> ......
> 
> Of course, the NULL check could then be removed.
> Jan Heckman

The above is somewhat misleading/incomplete.
Here is a diff (base 1.9.1) that checks envvar GML_DEFAULTFIELDTYPE for
assigning a default fieldtype if type is not specified in the schema. E.G.
GML_DEFAULTFIELDTYPE=STRING. Do not prefix, the code already does.
--------------------------start diff (winmerge)--------------------------
246c246,251
<     for( psAttrDef = psAttrSeq->psChild;
---
>     char *pszDefaultType=new char [48];
> 	sprintf(pszDefaultType,"xsd:%s",CPLGetConfigOption(
> "GML_DEFAULTFIELDTYPE", ""));
> 	if (pszDefaultType[4]=='\0') { delete [] pszDefaultType;
> pszDefaultType=NULL; }
> 	else CPLStrlwr(pszDefaultType);
> 
> 	for( psAttrDef = psAttrSeq->psChild;
260c265
<         /* MapServer WFS writes element type as an attribute of element */
---
> 		/* MapServer WFS writes element type as an attribute of element */
263a269
> 		if (pszElementName!=NULL && pszType == NULL) pszType=pszDefaultType;
-------------------end diff-------------------------



--
View this message in context: http://osgeo-org.1560.n6.nabble.com/gdal-dev-GDAL-GML-driver-and-xsd-schema-mapping-tp3742789p5023229.html
Sent from the GDAL - Dev mailing list archive at Nabble.com.


More information about the gdal-dev mailing list