Skip to content

Commit a7f69c6

Browse files
author
mhugent
committedJan 19, 2007
wfs fix also for the 0.8 branch
git-svn-id: http://svn.osgeo.org/qgis/branches/Release-0_8_0@6444 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 554a74a commit a7f69c6

File tree

1 file changed

+34
-21
lines changed

1 file changed

+34
-21
lines changed
 

‎src/providers/wfs/qgswfsprovider.cpp

+34-21
Original file line numberDiff line numberDiff line change
@@ -472,33 +472,46 @@ int QgsWFSProvider::readAttributesFromSchema(QDomDocument& schemaDoc, QString& g
472472
return 1;
473473
}
474474
QDomElement schemaElement = schemaNodeList.at(0).toElement();
475-
476-
//find <element name="tname" type = ...>
477-
QString complexTypeType;
478-
QDomNodeList typeElementNodeList = schemaElement.elementsByTagNameNS("http://www.w3.org/2001/XMLSchema", "element");
479-
QDomElement typeElement = typeElementNodeList.at(0).toElement();
480-
complexTypeType = typeElement.attribute("type");
475+
QDomElement complexTypeElement; //the <complexType> element corresponding to the feature type
481476

482-
if(complexTypeType.isEmpty())
483-
{
484-
return 3;
485-
}
477+
//find out, on which lines the first <element> or the first <complexType> occur. If <element> occurs first (mapserver), read the type of the relevant <complexType> tag. If <complexType> occurs first (geoserver), search for information about the feature type directly under this first complexType element
478+
479+
int firstElementTagPos = schemaElement.elementsByTagNameNS("http://www.w3.org/2001/XMLSchema", "element").at(0).toElement().columnNumber();
480+
int firstComplexTypeTagPos = schemaElement.elementsByTagNameNS("http://www.w3.org/2001/XMLSchema", "complexType").at(0).toElement().columnNumber();
486481

487-
//remove the namespace on complexTypeType
488-
if(complexTypeType.contains(":"))
482+
if(firstComplexTypeTagPos < firstElementTagPos)
489483
{
490-
complexTypeType = complexTypeType.section(":", 1, 1);
484+
//geoserver
485+
complexTypeElement = schemaElement.elementsByTagNameNS("http://www.w3.org/2001/XMLSchema", "complexType").at(0).toElement();
491486
}
492-
493-
//find <complexType name=complexTypeType
494-
QDomElement complexTypeElement;
495-
QDomNodeList complexTypeNodeList = schemaElement.elementsByTagNameNS("http://www.w3.org/2001/XMLSchema", "complexType");
496-
for(int i = 0; i < complexTypeNodeList.length(); ++i)
487+
else
497488
{
498-
if(complexTypeNodeList.at(i).toElement().attribute("name") == complexTypeType)
489+
//UMN mapserver
490+
QString complexTypeType;
491+
QDomNodeList typeElementNodeList = schemaElement.elementsByTagNameNS("http://www.w3.org/2001/XMLSchema", "element");
492+
QDomElement typeElement = typeElementNodeList.at(0).toElement();
493+
complexTypeType = typeElement.attribute("type");
494+
495+
if(complexTypeType.isEmpty())
499496
{
500-
complexTypeElement = complexTypeNodeList.at(i).toElement();
501-
break;
497+
return 3;
498+
}
499+
500+
//remove the namespace on complexTypeType
501+
if(complexTypeType.contains(":"))
502+
{
503+
complexTypeType = complexTypeType.section(":", 1, 1);
504+
}
505+
506+
//find <complexType name=complexTypeType
507+
QDomNodeList complexTypeNodeList = schemaElement.elementsByTagNameNS("http://www.w3.org/2001/XMLSchema", "complexType");
508+
for(int i = 0; i < complexTypeNodeList.length(); ++i)
509+
{
510+
if(complexTypeNodeList.at(i).toElement().attribute("name") == complexTypeType)
511+
{
512+
complexTypeElement = complexTypeNodeList.at(i).toElement();
513+
break;
514+
}
502515
}
503516
}
504517

0 commit comments

Comments
 (0)
Please sign in to comment.