ZVON > >
Prev | Next |

16. string-range Function

This tutorial is obsolete. Please, use the new one.

Description

For each location in the location-set argument, the function string-range returns a set of string ranges, a set of substrings in a string. Specifically, the string-value of the location is searched for substrings that match the string argument, and the resulting location-set will contain a range location for each non-overlapping match.




Ignoring element boundaries and entire embedded nodes
Element boundaries, as well as entire embedded nodes such as processing instructions and comments, are ignored as defined defined in XPath.
XPointer: xpointer(string-range(//*,'nestedelement'))

 <AAA>
   <BBB bbb="111">
     Text in the first element BBB.</BBB>
   <BBB bbb="222">
     Text in another element BBB.
     <DDD ddd="999">
       Text in more nested</DDD>element.</BBB>
   <CCC ccc="123" xxx="321">
     Again some text in some element.</CCC>
 </AAA>
  • X marks point (zero width)
  • This style marks the container node.
  • This style marks resulting locations.
  • X marks collapsed range (zero width)


Empty string matching
An empty string is considered to match before each character of the string-value and after the final character.
XPointer: xpointer(string-range(string-range(//DDD,'more')),'')

 <AAA>
   <BBB bbb="111">
     Text in the first element BBB.</BBB>
   <BBB bbb="222">
     Text in another element BBB.
     <DDD ddd="999">Text in XmXoXrXeX nested element.</DDD>
   </BBB>
   <CCC ccc="123" xxx="321">
     Again some text in some element.</CCC>
 </AAA>
  • X marks point (zero width)
  • This style marks the container node.
  • This style marks resulting locations.
  • X marks collapsed range (zero width)


Whitespace matching
Whitespace in a string is matched literally, with no normalization with the except that provided by XML for line ends.
XPointer: xpointer(string-range(//*,'in more'))

 <AAA>
   <BBB bbb="111">
     Text in the first element BBB.</BBB>
   <BBB bbb="222">
     Text in another element BBB.
     <DDD ddd="999">
       Text in more nested element.</DDD>
   </BBB>
   <CCC ccc="123" xxx="321">
     Again some text in some element.</CCC>
 </AAA>
  • X marks point (zero width)
  • This style marks the container node.
  • This style marks resulting locations.
  • X marks collapsed range (zero width)


Third and fourth argument (optional)
The third argument gives the position of the first character to be in the resulting range, relative to the start of the match (default is 1). The fourth argument gives the number of characters in the range (default is that the range extends to the end of the matched string).
XPointer: xpointer(string-range(//*,'another', 2, 3))

 <AAA>
   <BBB bbb="111">
     Text in the first element BBB.</BBB>
   <BBB bbb="222">
     Text in another element BBB.
     <DDD ddd="999">
       Text in more nested element.</DDD>
   </BBB>
   <CCC ccc="123" xxx="321">
     Again some text in some element.</CCC>
 </AAA>
  • X marks point (zero width)
  • This style marks the container node.
  • This style marks resulting locations.
  • X marks collapsed range (zero width)



_____________________________________________
Reference Search | Sitemap | XML Glossary       ZVON | Systinet