Invalid content was found starting with element 'LabelPlacement' 问题解决

8 篇文章 0 订阅
7 篇文章 0 订阅
本文介绍了解决GeoServer中样式验证错误的方法,通过调整TextSymbolizer元素的顺序,如Geometry、Label、Font等,可以消除错误提示。尽管这些错误不影响样式效果,但仍需按照正确的顺序排列以确保文件的有效性。
摘要由CSDN通过智能技术生成

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 之后。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值