indexing description: "Objects that ..." author: "" date: "$Date$" revision: "$Revision$" class XPATH inherit TWO_WAY_LIST[LOCATION_STEP] export {NONE} all end create make_from_path feature -- Creation make_from_path (xpath: STRING) is -- creates a new xpath object from the given xpath string local steps: LIST[STRING] do has_error := False steps := split_xpath (xpath) steps.start if steps.item.is_empty then extend (create {LOCATION_STEP}.make_root_step) steps.forth end from until steps.off loop extend (create {LOCATION_STEP}.make (steps.item)) steps.forth end end feature -- Status Information has_error: BOOLEAN feature -- Basic Operations select_nodes (node: XML_NODE) : XML_NODE_LIST is -- selects the nodes specified by this xpath instance from the given context node do create Result.make (Void) Result.append (node) from start until off loop Result := item.apply (Result) forth end end select_first_node (node: XML_NODE) : XML_NODE is -- selects the first node that matches this xpath starting from the given context node require valid_node: node /= Void local new: BOOLEAN do Result := node from start new := True until off or before loop Result := item.apply_single (Result, new) if Result = Void then back new := False else forth new := True end end end feature {NONE} -- Implementation split_xpath (xpath: STRING) : LIST[STRING] is -- splits the given xpath expression into location step strings local steps: LIST[STRING] do Result := xpath.split ('/') end end