mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-27 00:33:48 -05:00
[BUGFIX][Server] Enhance cleaning propertyname and searching by propertyname
This commit is contained in:
parent
e7d587f423
commit
24737be1b8
@ -263,7 +263,7 @@ namespace QgsWfs
|
||||
|
||||
//xsd:element
|
||||
QDomElement attElem = doc.createElement( QStringLiteral( "element" )/*xsd:element*/ );
|
||||
attElem.setAttribute( QStringLiteral( "name" ), attributeName.replace( ' ', '_' ) );
|
||||
attElem.setAttribute( QStringLiteral( "name" ), attributeName.replace( ' ', '_' ).replace( cleanTagNameRegExp, QLatin1String( "" ) ) );
|
||||
QVariant::Type attributeType = fields.at( idx ).type();
|
||||
if ( attributeType == QVariant::Int )
|
||||
attElem.setAttribute( QStringLiteral( "type" ), QStringLiteral( "integer" ) );
|
||||
|
@ -250,15 +250,21 @@ namespace QgsWfs
|
||||
QList<int> idxList;
|
||||
// build corresponding propertyname
|
||||
QList<QString> propertynames;
|
||||
QList<QString> fieldnames;
|
||||
for ( int idx = 0; idx < fields.count(); ++idx )
|
||||
{
|
||||
propertynames.append( fields.field( idx ).name().replace( ' ', '_' ) );
|
||||
fieldnames.append( fields[idx].name() );
|
||||
propertynames.append( fields.field( idx ).name().replace( ' ', '_' ).replace( cleanTagNameRegExp, QLatin1String( "" ) ) );
|
||||
}
|
||||
QString fieldName;
|
||||
for ( plstIt = propertyList.begin(); plstIt != propertyList.end(); ++plstIt )
|
||||
{
|
||||
fieldName = *plstIt;
|
||||
int fieldNameIdx = propertynames.indexOf( fieldName );
|
||||
if ( fieldNameIdx == -1 )
|
||||
{
|
||||
fieldNameIdx = fieldnames.indexOf( fieldName );
|
||||
}
|
||||
if ( fieldNameIdx > -1 )
|
||||
{
|
||||
idxList.append( fieldNameIdx );
|
||||
@ -1319,7 +1325,7 @@ namespace QgsWfs
|
||||
}
|
||||
QString attributeName = fields.at( idx ).name();
|
||||
|
||||
QDomElement fieldElem = doc.createElement( "qgs:" + attributeName.replace( ' ', '_' ) );
|
||||
QDomElement fieldElem = doc.createElement( "qgs:" + attributeName.replace( ' ', '_' ).replace( cleanTagNameRegExp, QLatin1String( "" ) ) );
|
||||
QDomText fieldText = doc.createTextNode( featureAttributes[idx].toString() );
|
||||
fieldElem.appendChild( fieldText );
|
||||
typeNameElement.appendChild( fieldElem );
|
||||
@ -1416,7 +1422,7 @@ namespace QgsWfs
|
||||
}
|
||||
QString attributeName = fields.at( idx ).name();
|
||||
|
||||
QDomElement fieldElem = doc.createElement( "qgs:" + attributeName.replace( ' ', '_' ) );
|
||||
QDomElement fieldElem = doc.createElement( "qgs:" + attributeName.replace( ' ', '_' ).replace( cleanTagNameRegExp, QLatin1String( "" ) ) );
|
||||
QDomText fieldText = doc.createTextNode( featureAttributes[idx].toString() );
|
||||
fieldElem.appendChild( fieldText );
|
||||
typeNameElement.appendChild( fieldElem );
|
||||
|
@ -58,6 +58,9 @@ namespace QgsWfs
|
||||
const QString OGC_NAMESPACE = QStringLiteral( "http://www.opengis.net/ogc" );
|
||||
const QString QGS_NAMESPACE = QStringLiteral( "http://www.qgis.org/gml" );
|
||||
|
||||
// Define clean tagName regExp
|
||||
const QRegExp cleanTagNameRegExp( "(?![\\w\\d\\.-])." );
|
||||
|
||||
} // namespace QgsWfs
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user