Hi,

I am by no means a master with regexp so I took the validation [a-z]+ from the 
mail by Giovanni and tested it with the http://www.regexr.com/ tool.

I do understand now that if I do not include anchors ^and $ then it is enough 
the find one validated character and therefore [a-z]+ accepts “wms-wfs” even 
dash is not included in regexp. But why [a-z]+ is also accepting “WMS-WFS”? 
Shouldn’t it be case sensitive?

I made some more tests and these two variants accept both all lower case and 
all upper case strings on Windows with Mapserver 7.0 from MS4W:

VALIDATION
            "db" "^[A-Z]+$"
END

VALIDATION
            "db" "^[a-z]+$"
END

-Jukka Rahkonen-




Lähettäjä: thomas bonfort [mailto:[email protected]]
Lähetetty: 16. toukokuuta 2016 15:31
Vastaanottaja: Rahkonen Jukka (MML)
Kopio: MapserverList OSGEO; G. Allegri
Aihe: Re: [mapserver-users] runtime CONNECTION string partial substitution


Not sure I get it. Your regex requires a letter or a dash , and one of them is 
present, no?
On May 16, 2016 2:28 PM, "Rahkonen Jukka (MML)" 
<[email protected]<mailto:[email protected]>>
 wrote:
Hi Thomas,

I was testing with http://www.regexr.com/ and it does not agree totally:

“wms-wfs” contains a dash and the test utility requires “[a-z-]+”
WMS-WFS has capital letters and dash and test utility requires “[A-Z-]+”

-Jukka-


Lähettäjä: thomas bonfort 
[mailto:[email protected]<mailto:[email protected]>]
Lähetetty: 16. toukokuuta 2016 15:11
Vastaanottaja: Rahkonen Jukka (MML)
Kopio: MapserverList OSGEO; G. Allegri
Aihe: Re: [mapserver-users] runtime CONNECTION string partial substitution


On May 16, 2016 2:02 PM, "Rahkonen Jukka (MML)" 
<[email protected]<mailto:[email protected]>>
 wrote:
>
> Correction:
>
>
>
> Changing the WMS online resource does work if the mapfile is written 
> correctly. I had to add VALIDATION also into MAP->WEB
>
>
>
> WEB
>
>     METADATA
>
> "wms_onlineresource" 
> "http://localhost:8060/cgi-bin/mapserv.exe?map=c:\ms4w\apps\wms-wfs.map&db=%db%";
>
>     END #metadata
>
>      VALIDATION
>
>              "db" "[a-z]+"
>
>     END #validation
>
> END #WEB
>
>
>
> Now I can send
> http://localhost:8060/cgi-bin/mapserv.exe?map=c:/ms4w/apps/wms-wfs.map&service=wms&version=1.3.0&request=getcapabilities&db=wms-wfs
>
>
>
> and get
> <OnlineResource 
> xlink:href="http://localhost:8060/cgi-bin/mapserv.exe?map=c:\ms4w\apps\wms-wfs.map&db=wms-wfs&"/>
>
>
>
> What is interesting is that the validation rule “[a-z]+” should not accept 
> the name of my db “wms-wfs” but it does. Capital letters are accepted as well 
> “WMS-WFS”. Because I am on Windows I can even get data with WMS-WFS though 
> the name of the db is “wms-wfs.sqlite”.
>
That's because [a-z]+ means "there should be at least one alphabetic character 
in the passed expression". The " correct" regex to use would be ^[a-z]+$

Thomas
>
>
> -Jukka Rahkonen-
>
>
>
>
>
> Lähettäjä: Rahkonen Jukka (MML)
> Lähetetty: 16. toukokuuta 2016 14:24
> Vastaanottaja: 'G. Allegri'; 
> [email protected]<mailto:[email protected]>
> Aihe: Re: [mapserver-users] runtime CONNECTION string partial substitution
>
>
>
> Hi,
>
>
>
> I made a test with your VALIDATION and CONNECTION and changing  db on-the-fly 
> works. How did you test?  If you use some WMS client for testing it is good 
> to remember that variable substitution does not have an effect on the 
> GetCapabilities document so that the GetMap URL would be updated 
> automatically. Therefore WMS clients like QGIS or OpenJUMP will drop the &db= 
> parameter from the GetMaps if you do not tell them not to trust the 
> advertised GetMap URL.
>
>
>
> According to documentation http://mapserver.org/cgi/runsub.html  it should 
> also be possible to use variable substitution also in MAP- WEB: METADATA. I 
> tried
>
> to use
>
> "wms_onlineresource" 
> “http://localhost:8060/cgi-bin/mapserv.exe?map=c:\ms4w\apps\wms-wfs.map&%db%”
>
>
>
> but GetCapabilities response contains the variable %db% literally
>
> <OnlineResource 
> xlink:href="http://localhost:8060/cgi-bin/mapserv.exe?map=c:\ms4w\apps\wms-wfs.map&%db%&"/>
>
>
>
> It seems that for getting a proper error message when &db= is missing or it 
> is wrong a WMS GetMap request is required. WFS GetFeature triggers the error
>
> and is easier to write by hand, for example:
>
> http://localhost:8060/cgi-bin/mapserv.exe?map=c:/ms4w/apps/wms-wfs.map&service=wfs&version=2.0.0&request=getfeature&typename=states&db=foo
>
> sends an error
>
> <ows:ExceptionText>
>
> msOGRFileOpen(): OGR error. Open failed for OGR connection in layer `states'. 
>  File not found or unsupported format.
>
> </ows:ExceptionText>
>
>
>
> Document http://www.mapserver.org/optimization/debugging.html contains good 
> advice for debugging.
>
>
>
> -Jukka Rahkonen-
>
>
>
>
>
> G. Allegri wrote:
>
>
>
> Hello,
>
> I'm trying to define a layer where the Sqlite DB connection should be set 
> dynamically through runtime sustitution.
>
>
>
> e.g.
>
>
>
> LAYER
>
>     NAME mylayer
>
>     TYPE POINT
>
>     CONNECTIONTYPE OGR
>
>     VALIDATION
>
>         "db" "[a-z]+"
>
>     END
>
>     CONNECTION "/var/www/dbs/%db%.sqlite"
>
>     DATA "mytable"
>
> END
>
>
>
> The point layers works fine if  %db% is set statically but if I try to define 
> it through get query values nothing is returned:
>
>
>
> http://localhost/cgi-bin/mapserv?map=mymapfile.map&db=mydb
>
>
>
> The documentation says that runtime sustitution should work for CONNECTION 
> param too. What am I doing wrong?
>
>
>
> Thanks,
>
> Giovanni
>
>
>
> --
>
> Giovanni Allegri
> http://about.me/giovanniallegri
>
> Gis3W - http://gis3w.it
>
> Ikare - http://ikare.it
>
> Twitter: https://twitter.com/_giohappy_
>
> blog: http://blog.spaziogis.it
> GEO+ geomatica in Italia http://bit.ly/GEOplus
>
>
> _______________________________________________
> mapserver-users mailing list
> [email protected]<mailto:[email protected]>
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
_______________________________________________
mapserver-users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/mapserver-users

Reply via email to