Search code examples
xmlxslt-2.0xpath-2.0

string length to find length of the repeating node


My xml looks like

<details>
  <addr>
      <streetAddressLine>90822 abc lane</streetAddressLine>
      <streetAddressLine>apt b</streetAddressLine>
      <!-- streetAddressLine element is repeatable -->
      <state>xyz</state>
  </addr>
</details>

I am looking for xpath expression which can give me the length of string-length(streetAddressLine[0]) + string-length (streetAddressLine[1]) + ..... + string-length(streetAddressLine[n])


Solution

  • string-length(string-join(/details/addr/streetAddressLine/text(),""))