Skip to content

Commit

Permalink
wfs fix also for the 0.8 branch
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/branches/Release-0_8_0@6444 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Jan 19, 2007
1 parent 554a74a commit a7f69c6
Showing 1 changed file with 34 additions and 21 deletions.
55 changes: 34 additions & 21 deletions src/providers/wfs/qgswfsprovider.cpp
Expand Up @@ -472,33 +472,46 @@ int QgsWFSProvider::readAttributesFromSchema(QDomDocument& schemaDoc, QString& g
return 1;
}
QDomElement schemaElement = schemaNodeList.at(0).toElement();

//find <element name="tname" type = ...>
QString complexTypeType;
QDomNodeList typeElementNodeList = schemaElement.elementsByTagNameNS("http://www.w3.org/2001/XMLSchema", "element");
QDomElement typeElement = typeElementNodeList.at(0).toElement();
complexTypeType = typeElement.attribute("type");
QDomElement complexTypeElement; //the <complexType> element corresponding to the feature type

if(complexTypeType.isEmpty())
{
return 3;
}
//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

int firstElementTagPos = schemaElement.elementsByTagNameNS("http://www.w3.org/2001/XMLSchema", "element").at(0).toElement().columnNumber();
int firstComplexTypeTagPos = schemaElement.elementsByTagNameNS("http://www.w3.org/2001/XMLSchema", "complexType").at(0).toElement().columnNumber();

//remove the namespace on complexTypeType
if(complexTypeType.contains(":"))
if(firstComplexTypeTagPos < firstElementTagPos)
{
complexTypeType = complexTypeType.section(":", 1, 1);
//geoserver
complexTypeElement = schemaElement.elementsByTagNameNS("http://www.w3.org/2001/XMLSchema", "complexType").at(0).toElement();
}

//find <complexType name=complexTypeType
QDomElement complexTypeElement;
QDomNodeList complexTypeNodeList = schemaElement.elementsByTagNameNS("http://www.w3.org/2001/XMLSchema", "complexType");
for(int i = 0; i < complexTypeNodeList.length(); ++i)
else
{
if(complexTypeNodeList.at(i).toElement().attribute("name") == complexTypeType)
//UMN mapserver
QString complexTypeType;
QDomNodeList typeElementNodeList = schemaElement.elementsByTagNameNS("http://www.w3.org/2001/XMLSchema", "element");
QDomElement typeElement = typeElementNodeList.at(0).toElement();
complexTypeType = typeElement.attribute("type");

if(complexTypeType.isEmpty())
{
complexTypeElement = complexTypeNodeList.at(i).toElement();
break;
return 3;
}

//remove the namespace on complexTypeType
if(complexTypeType.contains(":"))
{
complexTypeType = complexTypeType.section(":", 1, 1);
}

//find <complexType name=complexTypeType
QDomNodeList complexTypeNodeList = schemaElement.elementsByTagNameNS("http://www.w3.org/2001/XMLSchema", "complexType");
for(int i = 0; i < complexTypeNodeList.length(); ++i)
{
if(complexTypeNodeList.at(i).toElement().attribute("name") == complexTypeType)
{
complexTypeElement = complexTypeNodeList.at(i).toElement();
break;
}
}
}

Expand Down

0 comments on commit a7f69c6

Please sign in to comment.