Search code examples
xmlopenstreetmapgeoserver

XML, How to improve this part of code?


I am doing the color map on the geoserver, and need to check that all buildings have a gray color, but there are not all of them have "yes" the field "building", some have different key-words in the "landuse" field. If i pit code in this way, I have mistake:

line 72: cvc-complex-type.2.4.a: Invalid content was found starting with element 'And'. One of '{"www.opengis.net/ogc":comparisonOps, "www opengis net/ogc":spatialOps, "www opengis net/ogc":logicOps}' is expected. (Cannot put links)

The code:

 <Rule>
               <ogc:Filter>
               <ogc:Or>

              <ogc:PropertyIsEqualTo>
                <ogc:PropertyName>building</ogc:PropertyName>
                <ogc:Literal>yes</ogc:Literal>
              </ogc:PropertyIsEqualTo>

              <And>
                <And>
                  <And>
                    <And>
                      <And>
                        <And>
                     <ogc:PropertyIsEqualTo>
                <ogc:PropertyName>landuse</ogc:PropertyName>
                <ogc:Literal>basin</ogc:Literal>
              </ogc:PropertyIsEqualTo>
                      <ogc:PropertyIsEqualTo>
                <ogc:PropertyName>landuse</ogc:PropertyName>
                <ogc:Literal>farmland</ogc:Literal>
              </ogc:PropertyIsEqualTo>
              </And>
                         <ogc:PropertyIsEqualTo>
                <ogc:PropertyName>landuse</ogc:PropertyName>
                <ogc:Literal> forest </ogc:Literal>
              </ogc:PropertyIsEqualTo>
                      <ogc:PropertyIsEqualTo>
                <ogc:PropertyName>landuse</ogc:PropertyName>
                <ogc:Literal>grass</ogc:Literal>
              </ogc:PropertyIsEqualTo>
              </And>
                <ogc:PropertyIsEqualTo>
                <ogc:PropertyName>landuse</ogc:PropertyName>
                <ogc:Literal>greenhouse_horticulture</ogc:Literal>
              </ogc:PropertyIsEqualTo>
                      <ogc:PropertyIsEqualTo>
                <ogc:PropertyName>landuse</ogc:PropertyName>
                <ogc:Literal>landfill</ogc:Literal>
              </ogc:PropertyIsEqualTo>
              </And>
               <ogc:PropertyIsEqualTo>
                <ogc:PropertyName>landuse</ogc:PropertyName>
                <ogc:Literal>meadow</ogc:Literal>
              </ogc:PropertyIsEqualTo>
                      <ogc:PropertyIsEqualTo>
                <ogc:PropertyName>landuse</ogc:PropertyName>
                <ogc:Literal>orchard</ogc:Literal>
              </ogc:PropertyIsEqualTo>
              </And>
              <ogc:PropertyIsEqualTo>
                <ogc:PropertyName>landuse</ogc:PropertyName>
                <ogc:Literal>plant_nursery </ogc:Literal>
              </ogc:PropertyIsEqualTo>
                      <ogc:PropertyIsEqualTo>
                <ogc:PropertyName>landuse</ogc:PropertyName>
                <ogc:Literal>recreation_ground </ogc:Literal>
              </ogc:PropertyIsEqualTo>
              </And>
              <ogc:PropertyIsEqualTo>
                <ogc:PropertyName>landuse</ogc:PropertyName>
                <ogc:Literal>village_green</ogc:Literal>
              </ogc:PropertyIsEqualTo>
                      <ogc:PropertyIsEqualTo>
                <ogc:PropertyName>landuse</ogc:PropertyName>
                <ogc:Literal>vineyard</ogc:Literal>
              </ogc:PropertyIsEqualTo>
              </And>

            </ogc:Or>

      </ogc:Filter>

      <PolygonSymbolizer>
        <Fill>
          <CssParameter name="fill">
            <ogc:Literal>#A5A5A5</ogc:Literal>
          </CssParameter>
          <CssParameter name="fill-opacity">
            <ogc:Literal>1.0</ogc:Literal>
          </CssParameter>
        </Fill>
        <Stroke>
          <CssParameter name="stroke">
            <ogc:Literal>#6E6E6E</ogc:Literal>
          </CssParameter>


        </Stroke>
      </PolygonSymbolizer>
    </Rule>

Solution

  • The <And> element has to use the ogc namespace as well. You have to replace <And> with <ogc:And> (including the end tag as well of course).