xml/famXP.xp

(:
data model: tree of nodes
  item
    atomic values (neither parent nor children)
    nodes
      element
      attribute
      text
      namespace
      processing-instruction
      comment
      document-node
      

* (: current node:)
pers (: node pers in current:)
/pers (: root node pers:)
//chi (: all chi node, whereever in tree:)
pers/chi/pers (:per node in pers/chi:)
pers/chi/pers/@id  (: id attributes:)
//@id (: all attributes id:)
//pers[@id='g'] (: test:)
//pers[@id='g']/(self::* | .. | @id) (: list of nodes with | :)
string-join(//@id, '-') (: cat all @id values:)
pers/chi/concat(@id
,  ', join from children ', string-join(*/@id, '-')
,  ', from root ', string-join(/*/@id, '-')
,  ', from all ', string-join(//*/@id, '-')
)
 
//chi/concat(@id    (:axis use :: syntax :)
, ', join child ', string-join(child::*/@id, '-')
, ', descendant ', string-join(descendant::*/@id, '-')
, ', parent ', string-join(parent::*/@id, '-')
, ', ancestor-or-self ', string-join(ancestor-or-self::*/@id, '-')
)
:)

(: 
//pers/concat(@id    (:axis use :: syntax :)
, ', join preceding-sibling ', string-join(preceding-sibling::*/@id, '-')
, ', join following ', string-join(following::*/attribute::*, '-')
)

predicates

//chi[pers='florian'] 
| //*[text() = 'ursi']

//*[text() = 'walti']
//*[data() = 'waltigregordavidflorian']

let $p3  := math:pow(3, ?)  return $p3(5) (:let and dynmic function call :)

//pers[matches(text()[1], 'r.*i')]/@id
//pers[matches(string-join(text()), 'r.*i')]/@id 

for $x in -1 to 11 return concat($x, ' - ', $x*$x        (:for find nodes of this len:)
, ' ==> ', string-join(//*[string-length(text()[1]) =  $x]
  /concat(@id, '.', text()[1], ', ')))
:)
let $c := //chi, $p := $c/pers return $c = $p/..