#!/bin/csh

##
##  CSC 468: Spring 2008. Stage 3 test file
##
##  lab02-icde06.xml XPlite Queries
##
##  Alex Dekhtyar

## note: we use lab02-icde06.xml to test all basic XPlite functionality
##
## note: this script assumes that MiniXBase server is already running in a separate xterm window.




## Create repository, prepare data

java XpathPlus CREATE icde

java XpathPlus INSERT FILE icde lab02-icde06.xml

java XpathPlus LIST

java XpathPlus STATS icde

## Test individual axes

echo "/self::node()"
java XpathPlus document("icde")/self::node()
echo

echo "/child::node()"
java XpathPlus document("icde")/child::node()
echo

echo "/child::node()/child:node()/parent::node()"
java XpathPlus document("icde")/child::node()/child:node()/parent::node()
echo

echo "/child::nameOfConference"
java XpathPlus document("icde")/child::nameOfConference
echo

echo "/descendant::time"
java XpathPlus document("icde")/descendant::time()
echo

echo "/descendant::node()/ancestor::day"
java XpathPlus document("icde")/descendant::node()/ancestor::day"
echo

echo "/child::node()/child::node()/child::node()/child::endTime/following-sibling::node()"
java XpathPlus document("icde")/child::node()/child::node()/child::node()/child::endTime/following-sibling::node()
echo

echo "/child::node()/child::node()/child::node()/child::endTime/preceding-sibling::node()"
java XpathPlus document("icde")/child::node()/child::node()/child::node()/child::endTime/preceding-sibling::node()
echo

echo "/child::endDate/following::time"
java XpathPlus document("icde")/child::endDate/following::time
echo

echo "/child::endDate/preceding::node()"
java XpathPlus document("icde")/child::endDate/preceding::node()
echo

##
##  additional node test tests
##


echo "/descendant::session/descendant::*"
java XpathPlus document("icde")/descendant::session/descendant::*
echo

echo "/descendant::place/descendant::text()"
java XpathPlus document("icde")/descendant::place/descendant::text()"
echo

echo "/child::*/self::text()
java XpathPlus document("icde")/child::*/self::text()"
echo

echo "/child::text()
java XpathPlus document("icde")/child::text()"
echo


##
## attributes, etc...
##


echo "/descendant::node()/attribute::attribute()"
java XpathPlus document("icde")/descendant::node()/attribute::attribute()
echo

echo "/descendant::place/attribute::node()"
java XpathPlus document("icde")/descendant::place/attribute::node()"
echo

echo "/descendant::node()/attribute::name
java XpathPlus document("icde")/descendant::node()/attribute::name"
echo

echo "/descendant::node()/attribute::sessionname/parent::node()
java XpathPlus document("icde")/descendant::node()/attribute::sessionname/parent::node()"
echo


##
##  built-in functions
##

#
# position(),  operators
# 

echo "/child::node()[position() = 1]"
java XpathPlus document("icde")/child::node()[position() = 1]
echo



echo "/child::node()[position() <> 6]"
java XpathPlus document("icde")/child::node()[position() <> 6]
echo



echo "/child::node()[position() < 6]"
java XpathPlus document("icde")/child::node()[position() < 6]
echo



echo "/child::node()[position() <= 5]"
java XpathPlus document("icde")/child::node()[position() <= 5]
echo



echo "/child::node()[position() > 6]"
java XpathPlus document("icde")/child::node()[position() > 6]
echo



echo "/child::node()[position() >= 7]"
java XpathPlus document("icde")/child::node()[position() >= 7]
echo

#
#  last()
#


echo "/descendant::session/child::node()[last()=3]"
java XpathPlus document("icde")/descendant::session/child::node()[last()=3]
echo



echo "/descendant::day[last()=2]"
java XpathPlus document("icde")/descendant::day[last()=2]
echo


echo "/descendant::day[last()=1]"
java XpathPlus document("icde")/descendant::day[last()=1]
echo


#
# last(), position() combined
#



echo "/descendant::session[position() = last()]
java XpathPlus document("icde")/descendant::session[position() = last()]



echo "/descendant::session[position() < last()]
java XpathPlus document("icde")/descendant::session[position() < last()]
echo


echo "/descendant::session[position() > last()]"
java XpathPlus document("icde")/descendant::session[position() > last()]
echo


#
# string()
#

# for element nodes



echo '/descendant::session/child::time[string()="11:00 AM"]/parent::*'
java XpathPlus document("icde")/descendant::session/child::time[string()="11:00 AM"]/parent::*



echo '/descendant::session/child::time[string() <> "11:00 AM"]/parent::*'
java XpathPlus document("icde")/descendant::session/child::time[string() <> "11:00 AM"]/parent::*



echo '/descendant::presenter[string()="Paolo Atzeniy"]/parent::session/child::time'
java XpathPlus document("icde")//descendant::presenter[string()="Paolo Atzeniy"]/parent::session/child::time
echo


# for attributes


echo '/descendant::session/child::place/attribute::attribute()[name="Salon II"]/parent::*'
java XpathPlus document("icde")/descendant::session/child::place/attribute::attribute()[string()="Salon II"]/parent::*


echo '/descendant::session/child::place/attribute::attribute()[name <> "Salon II"]/parent::*'
java XpathPlus document("icde")/descendant::session/child::place/attribute::attribute()[string() <> "Salon II"]/parent::*


#
# conjunction of predicates
#



echo '/descendant::session/child::presenter[position() = 1][string()="Stefan Seltzsam"]'
java XpathPlus document("icde")/descendant::session/child::presenter[position() = 1][string()="Stefan Seltzsam"]



echo '/descendant::session/[position() < 5][position()>3]'
java XpathPlus document("icde")/descendant::session/[position() < 5][position()>3]


##
## XPlite expressions in  predicates
##


echo '/descendant::session/[child::presenter[last()> 2]]
java XpathPlus document("icde")/descendant::session/[child::presenter[last()> 2]]


echo '/descendant::place[attribute::attribute()[text="Salon II"]]'
java XpathPlus document("icde")/descendant::place[attribute::attribute()[text="Salon II"]]


echo '/descendant::place[following::place[attribute::name[string()="Tallahassee"]]'
java XpathPlus document("icde")/descendant::place[following::place[attribute::name[string()="Tallahassee"]]
echo










