i need to extract the version of a SLD file for GeoServer, which is an XML-based markup language. The version is an attribute of the element StyledLayerDescriptor.
Here is the xml file :
$ cat my_geoserver_sld_file.sld
<?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>230_sld_shp_line__230_test_sld_shp_line</Name>
        <UserStyle>
        <Title>A green line style</Title>
        <FeatureTypeStyle>
          <Rule>
             <Title>green line</Title>
             <LineSymbolizer>
               <Stroke>
                 <CssParameter name="stroke">#00ff00</CssParameter>
               </Stroke>
             </LineSymbolizer>
          </Rule>
        </FeatureTypeStyle>
      </UserStyle>
    </NamedLayer>
  </StyledLayerDescriptor>
I would like to set : version="1.0.0"
first the file was opened with de "xmllint --shell" command, in order to use xpath:
$ xmllint --shell my_geoserver_sld_file.sld
/ > xpath *
Object is a Node Set :
Set contains 1 nodes:
1  ELEMENT StyledLayerDescriptor
    default namespace href=http://www.opengis.net/sld
    namespace ogc href=http://www.opengis.net/ogc
    namespace xlink href=http://www.w3.org/1999/xlink
    namespace xsi href=http://www.w3.org/2001/XMLSchema-instanc...
    ATTRIBUTE version
      TEXT
        content=1.0.0
    ATTRIBUTE schemaLocation
      TEXT
        content=http://www.opengis.net/sld http://schema...
it should be simple to extract the version, but it fails...
/ > cat //StyledLayerDescriptor/version/text()
/ >
How can i set version in a bash variable ?