XML, 如何改进这部分代码?
XML, How to improve this part of code?
我正在地理服务器上做彩色地图,需要检查所有建筑物是否都有灰色,但并非所有建筑物都有 "yes" 字段 "building",有些有"landuse" 字段中的不同关键字。
如果我这样坑代码,我有错误:
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)
代码:
<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>
<And>
元素也必须使用 ogc
命名空间。您必须将 <And>
替换为 <ogc:And>
(当然也包括结束标记)。
我正在地理服务器上做彩色地图,需要检查所有建筑物是否都有灰色,但并非所有建筑物都有 "yes" 字段 "building",有些有"landuse" 字段中的不同关键字。 如果我这样坑代码,我有错误:
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)
代码:
<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>
<And>
元素也必须使用 ogc
命名空间。您必须将 <And>
替换为 <ogc:And>
(当然也包括结束标记)。