2

I frequently use QGIS to generate SLD stylesheets for geoserver layers. When I do it that way, namespace with value "se" is added to SLD tags.

Example:

<se:Rule>

When I make a stylesheet manually, I don't use namespace, and it works the same. Why is namespace added in this case?

3

XML prefixes don't mean anything, though by convention they are often chosen to relate to the schema they are importing. If you look at (usually) the first line of your XML you will see something like:

<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">

each xmlns is importing a schema that will be used later in the document. The first one in this case has nothing after it so it is the default, all tags with no prefix will be looked for in the schema that follows (http://www.opengis.net/sld), the others all define a prefix that tells the parser where the following tag can be found.

QGIS chooses to prefix some of it's tags with se: which points to http://www.opengis.net/se which is the OGC Symbology Encoding standard, while it's default remains the SLD standard, which is why UserStyle etc have no prefix.

<StyledLayerDescriptor xmlns="http://www.opengis.net/sld" version="1.1.0" 
  xmlns:se="http://www.opengis.net/se" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xsi:schemaLocation="http://www.opengis.net/sld 
  http://schemas.opengis.net/sld/1.1.0/StyledLayerDescriptor.xsd" 
  xmlns:ogc="http://www.opengis.net/ogc" 
  xmlns:xlink="http://www.w3.org/1999/xlink">

But the developers could have just as easily gone with:

<StyledLayerDescriptor xmlns="http://www.opengis.net/sld" version="1.1.0" 
  xmlns:n1="http://www.opengis.net/se" 
  xmlns:n2="http://www.w3.org/2001/XMLSchema-instance" 
  xsi:schemaLocation="http://www.opengis.net/sld 
  http://schemas.opengis.net/sld/1.1.0/StyledLayerDescriptor.xsd" 
  xmlns:n3="http://www.opengis.net/ogc" 
  xmlns:n4="http://www.w3.org/1999/xlink">

and it would not change the meaning of the document, only the prefixes used.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.