Closed abusquets closed 12 years ago
Hello abusquets,
At the current time, python-sld only supports one NamedLayer (as you have discovered).
What is the result of manually inserting the nodes? The code doc.create_namedlayer
may be returning the same node to you over & over again.
-David
I found a solution, I make a copy of element
doc = sld.StyledLayerDescriptor()
llista = MapStyle.objects.filter(map=2).order_by('order')
namedlayers=[]
for mapstyle in llista:
n = copy.copy(doc.create_namedlayer(mapstyle.style.name)._node)
namedlayers.append(n)
nl_node = doc._node.xpath('sld:NamedLayer', namespaces=sld.SLDNode._nsmap)[0]
doc._node.remove(nl_node)
i=0
for n in namedlayers:
doc._node.insert(i, n)
i=i+1
print etree.tostring(doc._node, with_tail=False, pretty_print=True)
I would like create and sld style with multiple NamedLayer This my code
doc = sld.StyledLayerDescriptor()
llista = MapStyle.objects.filter(map=id).order_by('order') for mapstyle in llista: nl = doc.create_namedlayer(mapstyle.style.name)
I created a namelayer for each element in llista but the result only includes the last NamedLayer.
I possible do this?
I try to do removing the namedlayer node and inserting after the namedlayer nodes but without success