I have created a Vue.js application that uses an OpenLayers map and I want to integrate a WMS layer that can dynamically change its style. My WMS layer displays the carbon emission of many entities of the world (countries, states, etc.) depending on the zoom level on the map. If you zoom out to the maximum only large federations will be displayed (Europe, China, Russia, etc.) and if you zoom in you will see the countries or regions of these federations (Spain, UK, states of USA).
To change the style after the corresponding zoom level I use the updateParams() function of the TileWMS class and I generate an xml style that I pass to the sld_body parameter of the query on my WMS layer. But when all the countries and regions of the federations are displayed the generated xml is very long and my request ends up with a URI too long error.
Here is the generated XML:
<?xml version="1.0" encoding="ISO-8859-1"?> <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">
<NamedLayer>
<Name>cite:v_province</Name>
<UserStyle>
<FeatureTypeStyle>
<Rule>
<Name>cite:v_province</Name>
<ogc:Filter>
<ogc:PropertyIsEqualTo>
<ogc:Function name="in">
<ogc:PropertyName>id</ogc:PropertyName>
<ogc:Literal>9</ogc:Literal>
<ogc:Literal>46</ogc:Literal>
<ogc:Literal>106</ogc:Literal>
<ogc:Literal>70</ogc:Literal>
</ogc:Function>
<ogc:Literal>true</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:Filter>
<PolygonSymbolizer>
<Fill>
<CssParameter name="fill">#FFEDA0</CssParameter>
</Fill>
</PolygonSymbolizer>
</Rule>
<Rule>
<Name>cite:v_province</Name>
<ogc:Filter>
<ogc:PropertyIsEqualTo>
<ogc:Function name="in">
<ogc:PropertyName>id</ogc:PropertyName>
<ogc:Literal>52</ogc:Literal>
<ogc:Literal>36</ogc:Literal>
<ogc:Literal>41</ogc:Literal>
<ogc:Literal>50</ogc:Literal>
<ogc:Literal>74</ogc:Literal>
<ogc:Literal>84</ogc:Literal>
<ogc:Literal>78</ogc:Literal>
<ogc:Literal>95</ogc:Literal>
<ogc:Literal>49</ogc:Literal>
<ogc:Literal>31</ogc:Literal>
<ogc:Literal>83</ogc:Literal>
<ogc:Literal>34</ogc:Literal>
<ogc:Literal>102</ogc:Literal>
<ogc:Literal>86</ogc:Literal>
<ogc:Literal>18</ogc:Literal>
<ogc:Literal>15</ogc:Literal>
<ogc:Literal>16</ogc:Literal>
<ogc:Literal>1</ogc:Literal>
<ogc:Literal>65</ogc:Literal>
<ogc:Literal>104</ogc:Literal>
<ogc:Literal>57</ogc:Literal>
<ogc:Literal>3</ogc:Literal>
<ogc:Literal>25</ogc:Literal>
<ogc:Literal>60</ogc:Literal>
<ogc:Literal>53</ogc:Literal>
<ogc:Literal>87</ogc:Literal>
<ogc:Literal>54</ogc:Literal>
<ogc:Literal>23</ogc:Literal>
<ogc:Literal>47</ogc:Literal>
<ogc:Literal>98</ogc:Literal>
<ogc:Literal>33</ogc:Literal>
<ogc:Literal>48</ogc:Literal>
<ogc:Literal>6</ogc:Literal>
<ogc:Literal>14</ogc:Literal>
<ogc:Literal>43</ogc:Literal>
<ogc:Literal>73</ogc:Literal>
<ogc:Literal>96</ogc:Literal>
<ogc:Literal>109</ogc:Literal>
<ogc:Literal>90</ogc:Literal>
<ogc:Literal>93</ogc:Literal>
<ogc:Literal>100</ogc:Literal>
<ogc:Literal>24</ogc:Literal>
<ogc:Literal>58</ogc:Literal>
<ogc:Literal>63</ogc:Literal>
<ogc:Literal>11</ogc:Literal>
<ogc:Literal>64</ogc:Literal>
<ogc:Literal>37</ogc:Literal>
<ogc:Literal>105</ogc:Literal>
<ogc:Literal>26</ogc:Literal>
</ogc:Function>
<ogc:Literal>true</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:Filter>
<PolygonSymbolizer>
<Fill>
<CssParameter name="fill">#FD8D3C</CssParameter>
</Fill>
</PolygonSymbolizer>
</Rule>
<Rule>
<Name>cite:v_province</Name>
<ogc:Filter>
<ogc:PropertyIsEqualTo>
<ogc:Function name="in">
<ogc:PropertyName>id</ogc:PropertyName>
<ogc:Literal>101</ogc:Literal>
<ogc:Literal>110</ogc:Literal>
<ogc:Literal>77</ogc:Literal>
<ogc:Literal>80</ogc:Literal>
<ogc:Literal>331</ogc:Literal>
<ogc:Literal>108</ogc:Literal>
<ogc:Literal>85</ogc:Literal>
<ogc:Literal>103</ogc:Literal>
<ogc:Literal>94</ogc:Literal>
<ogc:Literal>72</ogc:Literal>
<ogc:Literal>39</ogc:Literal>
<ogc:Literal>19</ogc:Literal>
<ogc:Literal>61</ogc:Literal>
<ogc:Literal>89</ogc:Literal>
<ogc:Literal>91</ogc:Literal>
<ogc:Literal>10</ogc:Literal>
<ogc:Literal>92</ogc:Literal>
<ogc:Literal>71</ogc:Literal>
<ogc:Literal>97</ogc:Literal>
<ogc:Literal>5</ogc:Literal>
</ogc:Function>
<ogc:Literal>true</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:Filter>
<PolygonSymbolizer>
<Fill>
<CssParameter name="fill">#FC4E2A</CssParameter>
</Fill>
</PolygonSymbolizer>
</Rule>
<Rule>
<Name>cite:v_province</Name>
<ogc:Filter>
<ogc:PropertyIsEqualTo>
<ogc:Function name="in">
<ogc:PropertyName>id</ogc:PropertyName>
<ogc:Literal>35</ogc:Literal>
<ogc:Literal>7</ogc:Literal>
<ogc:Literal>45</ogc:Literal>
<ogc:Literal>21</ogc:Literal>
<ogc:Literal>55</ogc:Literal>
<ogc:Literal>69</ogc:Literal>
<ogc:Literal>28</ogc:Literal>
<ogc:Literal>22</ogc:Literal>
<ogc:Literal>38</ogc:Literal>
<ogc:Literal>82</ogc:Literal>
<ogc:Literal>13</ogc:Literal>
<ogc:Literal>76</ogc:Literal>
<ogc:Literal>2</ogc:Literal>
<ogc:Literal>29</ogc:Literal>
<ogc:Literal>4</ogc:Literal>
<ogc:Literal>68</ogc:Literal>
<ogc:Literal>59</ogc:Literal>
<ogc:Literal>99</ogc:Literal>
<ogc:Literal>75</ogc:Literal>
<ogc:Literal>51</ogc:Literal>
<ogc:Literal>17</ogc:Literal>
<ogc:Literal>27</ogc:Literal>
<ogc:Literal>32</ogc:Literal>
<ogc:Literal>81</ogc:Literal>
</ogc:Function>
<ogc:Literal>true</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:Filter>
<PolygonSymbolizer>
<Fill>
<CssParameter name="fill">#FEB24C</CssParameter>
</Fill>
</PolygonSymbolizer>
</Rule>
<Rule>
<Name>cite:v_province</Name>
<ogc:Filter>
<ogc:PropertyIsEqualTo>
<ogc:Function name="in">
<ogc:PropertyName>id</ogc:PropertyName>
<ogc:Literal>42</ogc:Literal>
<ogc:Literal>12</ogc:Literal>
<ogc:Literal>20</ogc:Literal>
<ogc:Literal>40</ogc:Literal>
<ogc:Literal>88</ogc:Literal>
<ogc:Literal>56</ogc:Literal>
<ogc:Literal>67</ogc:Literal>
<ogc:Literal>30</ogc:Literal>
<ogc:Literal>8</ogc:Literal>
</ogc:Function>
<ogc:Literal>true</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:Filter>
<PolygonSymbolizer>
<Fill>
<CssParameter name="fill">#FED976</CssParameter>
</Fill>
</PolygonSymbolizer>
</Rule>
<Rule>
<Name>cite:v_province</Name>
<ogc:Filter>
<ogc:PropertyIsEqualTo>
<ogc:Function name="in">
<ogc:PropertyName>id</ogc:PropertyName>
<ogc:Literal>66</ogc:Literal>
<ogc:Literal>79</ogc:Literal>
<ogc:Literal>44</ogc:Literal>
<ogc:Literal>62</ogc:Literal>
</ogc:Function>
<ogc:Literal>true</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:Filter>
<PolygonSymbolizer>
<Fill>
<CssParameter name="fill">#E31A1C</CssParameter>
</Fill>
</PolygonSymbolizer>
</Rule>
</FeatureTypeStyle>
</UserStyle>
</NamedLayer>
<NamedLayer>
<Name>cite:v_static</Name>
<UserStyle>
<FeatureTypeStyle>
<Rule>
<Name>cite:v_static</Name>
<ogc:Filter>
<ogc:PropertyIsEqualTo>
<ogc:Function name="in">
<ogc:PropertyName>id</ogc:PropertyName>
<ogc:Literal>9</ogc:Literal>
</ogc:Function>
<ogc:Literal>true</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:Filter>
<PolygonSymbolizer>
<Fill>
<CssParameter name="fill">#E31A1C</CssParameter>
</Fill>
</PolygonSymbolizer>
</Rule>
<Rule>
<Name>cite:v_static</Name>
<ogc:Filter>
<ogc:PropertyIsEqualTo>
<ogc:Function name="in">
<ogc:PropertyName>id</ogc:PropertyName>
<ogc:Literal>1</ogc:Literal>
<ogc:Literal>5</ogc:Literal>
</ogc:Function>
<ogc:Literal>true</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:Filter>
<PolygonSymbolizer>
<Fill>
<CssParameter name="fill">#FD8D3C</CssParameter>
</Fill>
</PolygonSymbolizer>
</Rule>
<Rule>
<Name>cite:v_static</Name>
<ogc:Filter>
<ogc:PropertyIsEqualTo>
<ogc:Function name="in">
<ogc:PropertyName>id</ogc:PropertyName>
<ogc:Literal>4</ogc:Literal>
<ogc:Literal>6</ogc:Literal>
</ogc:Function>
<ogc:Literal>true</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:Filter>
<PolygonSymbolizer>
<Fill>
<CssParameter name="fill">#FC4E2A</CssParameter>
</Fill>
</PolygonSymbolizer>
</Rule>
</FeatureTypeStyle>
</UserStyle>
</NamedLayer>
How can I change my request so that passing a long XML is not a problem?