ZVON > >
Prev |

32. unique Predicate Function

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

Description

Allows testing whether an XPoint expression or sub-expression locates a singleton.




Singleton
The expression xpointer(//AAA/BBB[@bbb='222']) returns a singleton. Thus the unique() function returns true.
XPointer: xpointer(//AAA/BBB[@bbb='222'][unique()])

 <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)


Singleton
The expression xpointer(string-range(//AAA/BBB,'another')) returns a singleton. Thus the unique() function returns true.
XPointer: xpointer(string-range(//AAA/BBB,'another')[unique()])

 <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)


This is not a singleton
The result of the expression xpointer(//AAA/BBB) is not a singleton (the location-set consists of two locations). Thus the unique() function returns false.
XPointer: xpointer(//AAA/BBB[unique()])

 <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




Related sites:
  • dotNet Slackers - Your latest resource for ASP.NET
  • Dotnet Spider - Outsourcing and Offshore software development in India
  • XML - Xselerator, XSL Editor, BizTalk Utilities, XML Tutorials, Learn XML
  • Planet Source Code - The largest public source code database on the Internet
answering service VoIP Internettelefonie DSL, SDSL, ADSL