本文章主要介绍了Invalid content was found starting with element 'LabelPlacement' 问题解决,具有不错的的参考价值,希望对您有所帮助,如解说有误或未考虑完全的地方,请您留言指出,谢谢!

geoserver 样式验证报错:

line 91: cvc-complex-type.2.4.a: Invalid content was found starting with element 'LabelPlacement'. One of '{"http://www.opengis.net/sld":Fill, "http://www.opengis.net/sld":Graphic, "http://www.opengis.net/sld":Priority, "http://www.opengis.net/sld":VendorOption}' is expected.

报错了一波类似这样的错误,但样式能正常起效
google了一下,发现这一类错误,主要是排列顺序引起的。

<xsd:element name="TextSymbolizer" substitutionGroup="sld:Symbolizer">  
    <xsd:annotation>  
      <xsd:documentation>  
        A "TextSymbolizer" is used to render text labels according to  
        various graphical parameters.  
      </xsd:documentation>  
    </xsd:annotation>  
    <xsd:complexType>  
      <xsd:complexContent>  
        <xsd:extension base="sld:SymbolizerType">  
          <xsd:sequence>  
            <xsd:element ref="sld:Geometry" minOccurs="0"/>  
            <xsd:element ref="sld:Label" minOccurs="0"/>  
            <xsd:element ref="sld:Font" minOccurs="0"/>  
            <xsd:element ref="sld:LabelPlacement" minOccurs="0"/>  
            <xsd:element ref="sld:Halo" minOccurs="0"/>  
            <xsd:element ref="sld:Fill" minOccurs="0"/>  
            <!-- GeoServer specific extensions, these are not part of the SLD 1.0 standard -->  
            <xsd:element ref="sld:Graphic" minOccurs="0"/>  
            <xsd:element ref="sld:Priority" minOccurs="0"/>  
            <xsd:element ref="sld:VendorOption" minOccurs="0" maxOccurs="unbounded" />  
          </xsd:sequence>  
        </xsd:extension>  
      </xsd:complexContent>  
    </xsd:complexType>  
  </xsd:element>  

也就是样式的顺序是:Geometry>Label>Font>LabelPlacement>Halo>Fill
将其重新排列之后,该错误不见了。
附上完整的样式示例

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
<StyledLayerDescriptor version="1.0.0" 
                       xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd" 
                       xmlns:sld="http://www.opengis.net/sld" 
                       xmlns="http://www.opengis.net/sld" 
                       xmlns:ogc="http://www.opengis.net/ogc" 
                       xmlns:se="http://www.opengis.net/se" 
                       xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
 
  <NamedLayer> 
    <Name>path_name</Name> 
    <UserStyle> 
      <FeatureTypeStyle> 
        <sld:Rule> 
          <sld:Name>path_name</sld:Name> 
          <sld:Title>path_name</sld:Title>           
          <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc"> 
            <ogc:PropertyIsLessThan> 
              <ogc:PropertyName>type</ogc:PropertyName> 
              <ogc:Literal>3</ogc:Literal> 
            </ogc:PropertyIsLessThan> 
          </ogc:Filter> 
          <MinScaleDenominator>50000</MinScaleDenominator> 
          <MaxScaleDenominator>1000000</MaxScaleDenominator> 
 
          <sld:LineSymbolizer> 
            <sld:Stroke> 
              <sld:CssParameter name="stroke">#02a5da</sld:CssParameter> 
              <sld:CssParameter name="stroke-width">5</sld:CssParameter> 
              <sld:CssParameter name="stroke-opacity">0</sld:CssParameter> 
            </sld:Stroke> 
          </sld:LineSymbolizer> 
          <TextSymbolizer> 
            <Label> 
              <ogc:PropertyName>name</ogc:PropertyName> 
            </Label> 
            <Font> 
              <CssParameter name="font-family">宋体</CssParameter> 
              <CssParameter name="font-size">13</CssParameter> 
              <CssParameter name="font-style">normal</CssParameter> 
              <CssParameter name="font-weight">bold</CssParameter> 
              <CssParameter name="font-opacity">0.1</CssParameter> 
            </Font> 
            <LabelPlacement> 
              <LinePlacement /> 
            </LabelPlacement> 
            <Halo> 
              <Radius>1.5</Radius> 
              <Fill> 
                <CssParameter name="fill">#FFFFFF</CssParameter> 
              </Fill> 
            </Halo> 
            <Fill> 
              <CssParameter name="fill">#02a5da</CssParameter> 
            </Fill> 
            <VendorOption name="followLine">true</VendorOption> 
            <VendorOption name="maxAngleDelta">90</VendorOption> 
            <VendorOption name="maxDisplacement">100</VendorOption> 
            <VendorOption name="repeat">100</VendorOption> 
          </TextSymbolizer>			 
        </sld:Rule> 
 
        <sld:Rule> 
          <sld:Name>path_name2</sld:Name> 
          <sld:Title>path_name2</sld:Title> 
          <ogc:Filter> 
            <ogc:PropertyIsLessThan> 
              <ogc:PropertyName>type</ogc:PropertyName> 
              <ogc:Literal>6</ogc:Literal> 
            </ogc:PropertyIsLessThan> 
          </ogc:Filter> 
          <MinScaleDenominator>50</MinScaleDenominator> 
          <MaxScaleDenominator>50000</MaxScaleDenominator> 
           
          <sld:LineSymbolizer> 
            <sld:Stroke> 
              <sld:CssParameter name="stroke">#353535</sld:CssParameter> 
              <sld:CssParameter name="stroke-width">5</sld:CssParameter> 
              <sld:CssParameter name="stroke-opacity">0</sld:CssParameter> 
            </sld:Stroke> 
          </sld:LineSymbolizer> 
          <TextSymbolizer> 
            <Label> 
              <ogc:PropertyName>name</ogc:PropertyName> 
            </Label> 
            <Font> 
              <CssParameter name="font-family">宋体</CssParameter> 
              <CssParameter name="font-size">15</CssParameter> 
              <CssParameter name="font-style">normal</CssParameter> 
              <CssParameter name="font-weight">bold</CssParameter> 
            </Font> 
            <LabelPlacement> 
              <LinePlacement /> 
            </LabelPlacement> 
            <Halo> 
              <Radius>1.5</Radius> 
              <Fill> 
                <CssParameter name="fill">#FFFFFF</CssParameter> 
              </Fill> 
            </Halo> 
            <Fill> 
              <CssParameter name="fill">#02a5da</CssParameter> 
            </Fill> 
            <VendorOption name="followLine">true</VendorOption> 
            <VendorOption name="maxAngleDelta">90</VendorOption> 
            <VendorOption name="maxDisplacement">100</VendorOption> 
            <VendorOption name="repeat">5000</VendorOption> 
          </TextSymbolizer>			 
        </sld:Rule> 
 
      </FeatureTypeStyle> 
    </UserStyle> 
  </NamedLayer> 
</StyledLayerDescriptor> 

GeoServer的样式元素顺序比较严格,sld:Rule 也是。MinScaleDenominatorMaxScaleDenominator 需在ogc:Filter 之后。


发布评论
IT虾米网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!

获取线的中间点(postgis)详解
你是第一个吃螃蟹的人
发表评论

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。