Geoserver 到 PostGIS - 插入但不更新时换行有效

问题描述 投票:0回答:1

我一直在使用 geoserver 和 PostGIS 数据库来在 Openlayers 中显示、添加和更新标记。
我需要其中一个功能属性是具有多行且尊重换行符的文本。

插入效果很好,但是当我尝试更新现有功能时,更新过程似乎会删除换行符。

问题似乎来自 Geoserver,而不是 Openlayers 或 PostGIS。
为了证明 Geoserver 收到正确的事务,下面是我的 Openlayers 实现发送到 geoserver 的 WFS 事务示例:

<Transaction xmlns="http://www.opengis.net/wfs" service="WFS" version="1.1.0">
<Update typeName="namespace:layername" xmlns:feature="https://www.example.com/geoserver/namespace">
<Property><Name>nom</Name><Value>TestName</Value></Property>
<Property><Name>description</Name><Value>First line

One line break




Multiple line breaks</Value></Property>

<Filter xmlns="http://www.opengis.net/ogc"><FeatureId fid="236"/>/Filter>
</Update>
</Transaction>

如您所见,Geoserver 自然地识别 中的换行符。一切都好。

但是,当需要更新数据库时,Geoserver 会向 PostGIS 发送不带换行符的查询,如下所示:

Request: transaction
    service = WFS
    version = 1.1.0
    baseUrl = http://localhost:8080/geoserver/
    group[0] = wfs:update=net.opengis.wfs.impl.UpdateElementTypeImpl@5b3cc21a (filter: [ 236 ], handle: null, inputFormat: <unset>, srsName: null, typeName: {https://www.example.com/geoserver/namespace}layername)
    update[0]:
        property[0]:
            name = name
            value = TestNameproperty[0]:
            name = description
            value = First line One line break Multiple line breaksproperty[0]:            
        filter = [ 236 ]
        inputFormat = x-application/gml:3
        typeName = {https://www.example.com/geoserver/namespace}layername
    releaseAction = ALL

奇怪的是,当插入新功能时,geoserver正确地将换行符插入到PostGIS查询中! 只有在更新时才会删除换行符

这是一个实际的 Geoserver 错误还是我做错了什么?

属性的 postgis 列属于“字符变化”类型。不知道是否相关。

PS:我必须在交易中编辑掉几行带有 URL 的行,因为我的问题被标记为垃圾邮件...

postgis geoserver
1个回答
0
投票

XML 在解析时会吃掉除其中一个空白字符之外的所有空白字符。为了避免这种情况,您需要将它们隐藏在 CDATA 块中。

不知道为什么插入会起作用。

© www.soinside.com 2019 - 2024. All rights reserved.