4.
XML Namespaces
XPath
PB138
Shortcuts
● attribute:: -> @
● descendant-or-self -> //
find last element in third level of XML tree of the
document (nodetest *)
XPath predicates
● AXIS::NODETEST[predicate]
○ position()=1
○ position=last()
○ you can use or, and
● find full_address of Steven Segal
● find phones of Jirka Novák and Segal
● Find name of the Person living on street
'Uvoz 22'
Node sets and Union
● count(nodeset) counts number of nodes
● nodeset | nodeset creates union of nodesets
● count number of phone elements and person
elements together
● number of phones that contain number
sequence "77" use contains(string, string)
XPath + namespaces
● XPath evaluator always assumes no
namespace
XPath.setNamespaceContext(new
NamespaceContext() {
@Override
....
XmlSchema
● xmllint --schema mySchema.xsd
Schema Parts
● Elements
● Define messages element in your XSD
Complex Types
● Element is of Complex type when it may
contain other elements
●
● may contain sequence of elements (all,
choice....)
○ minOccurs
○ maxOccurs
● Create a message subelements
Elements with Elements
● What is a mixed element type?
● Element has only attributes but no text. What
kind of type is that?
Simple Types
● We may specify precisely by inheritance
○ name is special type of string
○ date is special type of string
○ positive integer is special type of string
Elements with Attributes
● What kind of type they have? Simple or
Complex?