Skip to main content
Question

XML filter for WFS: filtering multiple values (more than 2)

  • January 31, 2019
  • 4 replies
  • 346 views

fikusas
Contributor
Forum|alt.badge.img+5

I'm having a problem using WFS XML filter. I'm trying to read only 6 features from entire dataset and I get the following error:

0684Q00000ArDGOQA3.png

I wrote query in SQL and need to convert it to XML:

"SAV_ID" IN (21,23,25,55,56,88)

Interestingly when I'm quering only 2 of thoses features, I get no errors. XML filter (working one) for 2 features is:

<ogc:Filter>
    <ogc:Or>
        <ogc:PropertyIsEqualTo>
            <ogc:PropertyName>SAV_ID</ogc:PropertyName>
            <ogc:Literal>21</ogc:Literal>
        </ogc:PropertyIsEqualTo>
        <ogc:PropertyIsEqualTo>
            <ogc:PropertyName>SAV_ID</ogc:PropertyName>
            <ogc:Literal>23</ogc:Literal>
        </ogc:PropertyIsEqualTo>
    </ogc:Or>
</ogc:Filter>

I tried the following variants (for more than 2 features):

(1) (gives error)

<ogc:Filter>
    <ogc:Or>
        <ogc:PropertyIsEqualTo>
            <ogc:PropertyName>SAV_ID</ogc:PropertyName>
            <ogc:Literal>21</ogc:Literal>
        </ogc:PropertyIsEqualTo>
        <ogc:PropertyIsEqualTo>
            <ogc:PropertyName>SAV_ID</ogc:PropertyName>
            <ogc:Literal>23</ogc:Literal>
        </ogc:PropertyIsEqualTo>
        <ogc:PropertyIsEqualTo>
            <ogc:PropertyName>SAV_ID</ogc:PropertyName>
            <ogc:Literal>25</ogc:Literal>
        </ogc:PropertyIsEqualTo>
        <ogc:PropertyIsEqualTo>
            <ogc:PropertyName>SAV_ID</ogc:PropertyName>
            <ogc:Literal>55</ogc:Literal>
        </ogc:PropertyIsEqualTo>
    </ogc:Or>
</ogc:Filter>

(2) (gives error)

<ogc:Filter>
    <ogc:Or>
        <ogc:PropertyIsEqualTo>
            <ogc:PropertyName>SAV_ID</ogc:PropertyName>
            <ogc:Literal>21</ogc:Literal>
        </ogc:PropertyIsEqualTo>
        <ogc:PropertyIsEqualTo>
            <ogc:PropertyName>SAV_ID</ogc:PropertyName>
            <ogc:Literal>23</ogc:Literal>
        </ogc:PropertyIsEqualTo>
        <ogc:PropertyIsEqualTo>
    </ogc:Or>
    <ogc:Or>
            <ogc:PropertyName>SAV_ID</ogc:PropertyName>
            <ogc:Literal>25</ogc:Literal>
        </ogc:PropertyIsEqualTo>
        <ogc:PropertyIsEqualTo>
            <ogc:PropertyName>SAV_ID</ogc:PropertyName>
            <ogc:Literal>55</ogc:Literal>
        </ogc:PropertyIsEqualTo>
    </ogc:Or>
</ogc:Filter>

(3)

<ogc:Filter>
        <ogc:PropertyIsEqualTo>
        <ogc:Function name "in">
            <ogc:PropertyName>SAV_ID</ogc:PropertyName>
            <ogc:Literal>21</ogc:Literal>
            <ogc:Literal>23</ogc:Literal>
            <ogc:Literal>25</ogc:Literal>
            <ogc:Literal>55</ogc:Literal>
        </ogc:Function name "in">
        </ogc:PropertyIsEqualTo>
</ogc:Filter>

Last one (3) downloads all the features. Any help on that?

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

4 replies

trentatsafe
Safer
Forum|alt.badge.img+6
  • Safer
  • 278 replies
  • February 4, 2019

Hello @fikusas,

 

 

I did some tinkering with the XML Filtering on a WFS and your first approach did work for me. Using the following Filter, gave me 4 results:
<ogc:Filter>
        <ogc:PropertyIsEqualTo>
                <ogc:PropertyName>VendorID</ogc:PropertyName>
                <ogc:Literal>1</ogc:Literal>
        </ogc:PropertyIsEqualTo>
        <ogc:PropertyIsEqualTo>
                <ogc:PropertyName>VendorID</ogc:PropertyName>
                <ogc:Literal>3</ogc:Literal>
        </ogc:PropertyIsEqualTo>
        <ogc:PropertyIsEqualTo>
                <ogc:PropertyName>VendorID</ogc:PropertyName>
                <ogc:Literal>4</ogc:Literal>
        </ogc:PropertyIsEqualTo>
        <ogc:PropertyIsEqualTo>
                <ogc:PropertyName>VendorID</ogc:PropertyName>
                <ogc:Literal>10</ogc:Literal>
        </ogc:PropertyIsEqualTo>
</ogc:Filter>

 

Are you able to share the WFS you are working with? Also, does your WFS GetCapabilities support the Filters you are trying to use?

fikusas
Contributor
Forum|alt.badge.img+5
  • Author
  • Contributor
  • 75 replies
  • February 5, 2019

I'm attaching GetCapabilities XML. It would be strange if quering more than 2 values isn't supported...

wfsserver.xml


trentatsafe
Safer
Forum|alt.badge.img+6
  • Safer
  • 278 replies
  • February 5, 2019

Hello @fikusas,

 

 

Your XML Filter(for the (1) option) does look correct, testing its structure with our WFS values worked. I do wonder are you using the 'Prefer HTTP Post, If Available' parameter on the Reader. This will allow you to not be limited on the URL that is sent. If you can ensure this is toggled to Yes.

 

 

You might be running into a character limit on the URL via the Get Request that is being sent. Try switching to Post, and let me know if that works.

fikusas
Contributor
Forum|alt.badge.img+5
  • Author
  • Contributor
  • 75 replies
  • February 6, 2019

I turned on "Prefer dataset URL" option on the Reader and it worked like a charm! Thanks for the insights.