SAXParseException Geoserevr SLD错误

时间:2016-12-31 08:26:39

标签: c# openlayers geoserver sld

我想动态更改wms图层的SLD。在SLD字符串中,我有CssParameter XML标记,它具有像#"#ff0000"这样的Hex颜色代码。当我将它发布到Geoserver时,我收到了这个错误:

java.lang.RuntimeException:org.xml.sax.SAXParseException; lineNumber:1; columnNumber:619; XML文档结构必须在同一实体中开始和结束。 org.xml.sax.SAXParseException; lineNumber:1; columnNumber:619; XML文档结构必须在同一实体中开始和结束。 XML文档结构必须在同一实体中开始和结束

这是指它有#charachter的行。 这是代码示例:

var SLD = '<?xml version="1.0" encoding="UTF-8"?><StyledLayerDescriptor version="1.0.0" xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd" xmlns="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:se="http://www.opengis.net/se">';
    SLD += '<NamedLayer><Name>pmo:iczmoagriculturemokran</Name><UserStyle><Name>pmo:iczmoagriculturemokran</Name><Title>Green polygon</Title><Abstract>Green fill with black outline</Abstract><FeatureTypeStyle><Rule><PolygonSymbolizer><Fill><CssParameter name="fill">#ff0000</CssParameter></Fill><Stroke /></PolygonSymbolizer></Rule></FeatureTypeStyle></UserStyle></NamedLayer></StyledLayerDescriptor>';

    SLD = encodeURI(SLD);
    var source = layer.WMSLayer.getSource();
    source.updateParams({ STYLES: undefined, SLD_BODY: SLD });

1 个答案:

答案 0 :(得分:3)

您可以将颜色的十六进制值转换为基数10.例如,在CssParameter标记中使用4359924(BASE 10)而不是#4286f4(BASE 16):

   Java.Lang.IllegalStateException: Activity has been destroyed
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/3511/77cb8568/source/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143
  at Java.Interop.JniEnvironment+InstanceMethods.CallIntMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniMethodInfo method) [0x00084] in /Users/builder/data/lanes/3511/ce955cc0/source/Java.Interop/src/Java.Interop/Java.Interop/JniEnvironment.g.cs:11464
  at Android.Runtime.JNIEnv.CallIntMethod (System.IntPtr jobject, System.IntPtr jmethod) [0x00000] in /Users/builder/data/lanes/3511/ce955cc0/source/monodroid/src/Mono.Android/JNIEnv.g.cs:186
  at Android.Support.V4.App.FragmentTransactionInvoker.CommitAllowingStateLoss () [0x00033] in <27c17fe440cf491ba8255bcefade6e02>:0
  at Xamarin.Forms.Platform.Android.AppCompat.MasterDetailContainer.Dispose (System.Boolean disposing) [0x00042] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\AppCompat\MasterDetailContainer.cs:130
  at Java.Lang.Object.Dispose () [0x00000] in /Users/builder/data/lanes/3511/ce955cc0/source/xamarin-android/src/Mono.Android/Java.Lang/Object.cs:203
  at Xamarin.Forms.Platform.Android.AppCompat.MasterDetailPageRenderer.Dispose (System.Boolean disposing) [0x00046] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\AppCompat\MasterDetailPageRenderer.cs:192
  at Java.Lang.Object.Dispose () [0x00000] in /Users/builder/data/lanes/3511/ce955cc0/source/xamarin-android/src/Mono.Android/Java.Lang/Object.cs:203
  at Xamarin.Forms.Platform.Android.AppCompat.Platform.SetPage (Xamarin.Forms.Page newRoot) [0x0003f] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\AppCompat\Platform.cs:226
  at Xamarin.Forms.Platform.Android.AppCompat.Platform.Dispose () [0x00010] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\AppCompat\Platform.cs:52
  at Xamarin.Forms.Platform.Android.FormsAppCompatActivity.OnDestroy () [0x0002f] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\AppCompat\FormsAppCompatActivity.cs:195
  at Android.App.Activity.n_OnDestroy (System.IntPtr jnienv, System.IntPtr native__this) [0x00009] in /Users/builder/data/lanes/3511/ce955cc0/source/monodroid/src/Mono.Android/platforms/android-24/src/generated/Android.App.Activity.cs:2981
  at at (wrapper dynamic-method) System.Object:3a1f2dcb-839c-41c3-88f3-3ca5ed8f0b6f (intptr,intptr)
  at java.lang.IllegalStateException: Activity has been destroyed
  at at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1515)
  at at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:638)
  at at android.support.v4.app.BackStackRecord.commitAllowingStateLoss(BackStackRecord.java:621)
  at at md5b60ffeb829f638581ab2bb9b1a7f4f3f.FormsAppCompatActivity.n_onDestroy(Native Method)
  at at md5b60ffeb829f638581ab2bb9b1a7f4f3f.FormsAppCompatActivity.onDestroy(FormsAppCompatActivity.java:80)
  at at android.app.Activity.performDestroy(Activity.java:5603)
  at at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1135)
  at at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3670)
  at at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3701)
  at at android.app.ActivityThread.access$1500(ActivityThread.java:161)
  at at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1318)
  at at android.os.Handler.dispatchMessage(Handler.java:102)
  at at android.os.Looper.loop(Looper.java:157)
  at at android.app.ActivityThread.main(ActivityThread.java:5356)
  at at java.lang.reflect.Method.invokeNative(Native Method)
  at at java.lang.reflect.Method.invoke(Method.java:515)
  at at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
  at at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
  at at dalvik.system.NativeStart.main(Native Method)