0

I made a SLD styling file, and I want to change SVG resource dynamically, by using function 'env', so that I can pass the parameter 'href' on client-side.

On the other hand, it's acceptable to change the Node <Rule> or <Graphic> or other Nodes, but in the way that using function 'env' to pass the parameter.

<?xml version="1.0" encoding="ISO-8859-1"?>
<StyledLayerDescriptor version="1.0.0" xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.0.0/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>achbrt_area</Name>
    <UserStyle>
      <Title>achbrt_area</Title>
      <FeatureTypeStyle>
        <Rule>
          <Title>achbrt_area</Title>
          <PointSymbolizer>
            <Graphic>
              <ExternalGraphic xmlns="http://www.opengis.net/sld" xmlns:xlink="http://www.w3.org/1999/xlink">
                <OnlineResource xlink:type="simple" xlink:href="ACHBRT07.svg" />
                <Format>image/svg+xml</Format>
              </ExternalGraphic>
              <Size>16</Size>
            </Graphic>
          </PointSymbolizer>
        </Rule>
      </FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>

Turn ACHBRT07.svg to ACHBRT08.svg

1 Answer 1

0

That would open up a huge security risk so I'm pretty sure you can't do it. Maybe you could use an environment variable in a filter to chose different Rules to achieve the same effect.

1
  • what about <OnlineResource xlink:type="simple" xlink:href="ACHBRT${env('ImgIndex')}.svg" /> I tried and it's indeed effective, although it may cause to potential safety hazards Commented Jul 29, 2024 at 3:21

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.