title: Xpath only select attribute with empty value
body: <p>How do I format this expression so that when a for-loop is running it only selects where analysis attributes are empty. The reason is that there are multiple templateNames with the same values. This is my attempt but can't get to work </p>
  
  <pre><code>String theXpath = "//report-plan[@name='"+ templateName +"']/settings/@analysis=''";
  </code></pre>
  
  <p>Sample code:</p>
  
  <pre><code>public class XPathTestReports {
      public static void main(String[] args) {
          try {
              String outputFile = "c:/workspace/samplenew.xml";
              String inputFile = "c:/workspace/sample.xml";
  
              Document doc = DocumentBuilderFactory.newInstance()
              .newDocumentBuilder().parse(new InputSource(inputFile));
  
              // locate the node(s)
              XPath xpath = XPathFactory.newInstance().newXPath();
  
              // lOAD THE File
              CSVImporterReports loader = new CSVImporterReports("C:/REPORT_TEMPLATES.csv");
              List &lt; OnConfig &gt; entries = loader.getEntries();
  
              for (OnConfig c: entries) {
                  String templateName = c.getTemplateName();
                  String analName = c.getAnalysisName();
                  String paramName = c.getParamName();
                  String theXpath = "//report-plan[@name='" + templateName + "']/settings/@analysis=''";
                  NodeList nodes = (NodeList) xpath.evaluate(theXpath, doc, XPathConstants.NODESET);
  
                  // make the change
                  for (int i = 0; i &lt; nodes.getLength(); i++) {
                      nodes.item(i).setTextContent(analName);
                      // nodes.item(i).setTextContent(paramName);
                  }
              }
  
              try {
                  // save the result
                  Transformer xformer = TransformerFactory.newInstance().newTransformer();
                  xformer.transform(new DOMSource(doc), new StreamResult(new File(outputFile)));
              } catch (TransformerConfigurationException e) {
                  // TODO Auto-generated catch block
              } catch (TransformerFactoryConfigurationError e) {
                  // TODO Auto-generated catch block
              } catch (TransformerException e) {
                  // TODO Auto-generated catch block
              }
          } catch (FileNotFoundException e) {
              e.printStackTrace();
          } catch (SAXException e) {
              e.printStackTrace();
          } catch (IOException e) {
              e.printStackTrace();
          } catch (ParserConfigurationException e) {
              e.printStackTrace();
          } catch (XPathExpressionException e) {
              e.printStackTrace();
          }
      }
  }
  </code></pre>
  
  <p>Sample XML:</p>
  
  <pre><code>&lt;report-plan name="generic"&gt;
                &lt;columns&gt;
                  &lt;column name="Nominal" subtotal-function="Sum" total-function="Sum"/&gt;
                  &lt;column name="Trade"/&gt;
                &lt;/columns&gt;
                &lt;settings analysis="" analysisParameters="" filtering-enabled="true" object-actions="false" show-object-actions="true" sorting-enabled="true"/&gt;
  &lt;/report-plan&gt;
  &lt;report-plan name="generic"&gt;
                &lt;columns&gt;
                  &lt;column name="Nominal" subtotal-function="Sum" total-function="Sum"/&gt;
                  &lt;column name="Trade"/&gt;
                &lt;/columns&gt;
                &lt;settings analysis="" analysisParameters="" filtering-enabled="true" object-actions="false" show-object-actions="true" sorting-enabled="true"/&gt;
  &lt;/report-plan&gt;
  &lt;report-plan name="sensitive"&gt;
                &lt;columns&gt;
                  &lt;column name="Nominal" subtotal-function="Sum" total-function="Sum"/&gt;
                  &lt;column name="Trade"/&gt;
                &lt;/columns&gt;
                &lt;settings analysis="" analysisParameters="" filtering-enabled="true" object-actions="false" show-object-actions="true" sorting-enabled="true"/&gt;
  &lt;/report-plan&gt;
  </code></pre>
  
  <p>At the moment my code is inputting the same value for both reports named generic. Even though the analysis attributes have different values to be entered. I need the code to enter in different analysis values even if the report names are the same.</p>
  
  <p>Output:</p>
  
  <pre><code>&lt;report-plan name="generic"&gt;
                &lt;columns&gt;
                  &lt;column name="Nominal" subtotal-function="Sum" total-function="Sum"/&gt;
                  &lt;column name="Trade"/&gt;
                &lt;/columns&gt;
                &lt;settings analysis="newValue" analysisParameters="" filtering-enabled="true" object-actions="false" show-object-actions="true" sorting-enabled="true"/&gt;
  &lt;/report-plan&gt;
  &lt;report-plan name="generic"&gt;
                &lt;columns&gt;
                  &lt;column name="Nominal" subtotal-function="Sum" total-function="Sum"/&gt;
                  &lt;column name="Trade"/&gt;
                &lt;/columns&gt;
                &lt;settings analysis="newValue" analysisParameters="" filtering-enabled="true" object-actions="false" show-object-actions="true" sorting-enabled="true"/&gt;
  &lt;/report-plan&gt;
  &lt;report-plan name="sensitive"&gt;
                &lt;columns&gt;
                  &lt;column name="Nominal" subtotal-function="Sum" total-function="Sum"/&gt;
                  &lt;column name="Trade"/&gt;
                &lt;/columns&gt;
                &lt;settings analysis="someValue" analysisParameters="" filtering-enabled="true" object-actions="false" show-object-actions="true" sorting-enabled="true"/&gt;
  &lt;/report-plan&gt;
  </code></pre>
  
  <p>CSV sample</p>
  
  <pre><code>TEMPLATE_NAME   ANALYSIS_NAME   PARAM_NAME
  generic         analval1        paramval1
  generic         analval2        paramval2
  sensitivity     analval3        paramval3
  </code></pre>