XML CDATA

最近在尝试用osgearth做个三维数据展示平台,看到 feature_stencil_polygon_draping.earth中的代码:

 

<map name="Feature Stencil Demo" type="geocentric" version="2">

 


  <options lighting="false"/>


  <image name="world" driver="gdal">
    <url>/data/world.tif</url>
  </image>


  <model name="countries" driver="feature_stencil">


    <!-- Configure the OGR feature driver to read the shapefile.
             Applying a slight negative buffer will "erode" the
             shapes, highlighting the borders between countries. -->


    <features name="states" driver="ogr">
      <url>/data/world.shp</url>
      <buffer distance="-0.05"/>
    </features>


    <!-- Since some countries span large areas on the globe, we need to
             use a larger-than-normal extrusion distance on the stencil
             volumes. (300000 is the default for a geocentric map.) -->


    <extrusion_distance>400000</extrusion_distance>


    <!-- Define a feature style class for each category: -->


    <styles>


      <style type="text/css">
        p1 {
        fill: #ffff80;
        fill-opacity: 0.4;
        }
        p2 {
        fill: #fad155;
        fill-opacity: 0.4;
        }
        p3 {
        fill: #f2a82f;
        fill-opacity: 0.4;
        }
        p4 {
        fill: #b3520d;
        fill-opacity: 0.4;
        }
        p5 {
        fill: #6a0000;
        fill-opacity: 0.4;
        }
      </style>


      <selector class="p1">
        <query>
          <expr><![CDATA[ POP_CNTRY <= 14045470 ]]></expr>
        </query>
      </selector>


      <selector class="p2">
        <query>
          <expr><![CDATA[ POP_CNTRY > 14045470 and POP_CNTRY <= 43410900 ]]></expr>
        </query>
      </selector>


      <selector class="p3">
        <query>
          <expr><![CDATA[ POP_CNTRY > 43410900 and POP_CNTRY <= 97228750 ]]></expr>
        </query>
      </selector>


      <selector class="p4">
        <query>
          <expr><![CDATA[ POP_CNTRY > 97228750 and POP_CNTRY <= 258833000 ]]></expr>
        </query>
      </selector>


      <selector class="p5">
        <query>
          <expr><![CDATA[ POP_CNTRY > 258833000 ]]></expr>
        </query>
      </selector>


    </styles>


  </model>

 

 

</map>

 

 

其中CDATA

 

术语 CDATA 指的是不应由 XML 解析器进行解析的文本数据(Unparsed Character Data)。

在 XML 元素中,"<" 和 "&" 是非法的。

"<" 会产生错误,因为解析器会把该字符解释为新元素的开始。

"&" 也会产生错误,因为解析器会把该字符解释为字符实体的开始。

某些文本,比如 JavaScript 代码,包含大量 "<" 或 "&" 字符。为了避免错误,可以将脚本代码定义为 CDATA。

CDATA 部分中的所有内容都会被解析器忽略。

CDATA 部分由 "<![CDATA[" 开始,由 "]]>" 结束:

<script>
<![CDATA[
function matchwo(a,b)
{
if (a < b && a < 0) then
  {
  return 1;
  }
else
  {
  return 0;
  }
}
]]>
</script>

在上面的例子中,解析器会忽略 CDATA 部分中的所有内容。

关于 CDATA 部分的注释:

CDATA 部分不能包含字符串 "]]>"。也不允许嵌套的 CDATA 部分。

标记 CDATA 部分结尾的 "]]>" 不能包含空格或折行。

最后求关注,求点赞,欢迎大家关注我的公众号
在这里插入图片描述
记录所学所用,包括但不限于遥感、地信、气象、生态环境,机器学习知识,相关文献阅读,编程代码实现。偶尔荒腔走板的聊聊其他。欢迎不同领域的朋友们加入进来,多多交流。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值