XPath over XML Schema: Examples
Contents
Sample XSD used in examples Boilerplate
Examples: 1, 2, 3, 4, 5, 6 (more examples in the download).
Example 2: /ex:Collection//ex:*
public static List<PathElement> example2(SchemaData schData) { XPath xpath = new XPath("/ex:Collection//ex:*"); // analyse XPath List<PathElement> matched = null; try { matched = xpath.analyse(schData, null); } catch (XPathException e) { System.err.println(e.getMessage()); } // print goog nodes printMatchedNodes(matched); return matched; }
Output
Matched nodes: /Collection[1,1](50:3)/Addresses[1,1](53:7) /Collection[1,1](50:3)/Deliveries[1,1](54:7) /Collection[1,1](50:3)/Addresses[1,1](53:7)/Address[0,inf](38:7) /Collection[1,1](50:3)/Deliveries[1,1](54:7)/Delivery[0,inf](46:7) /Collection[1,1](50:3)/Addresses[1,1](53:7)/Address[0,inf](38:7)/Line1[1,1](14:7) /Collection[1,1](50:3)/Addresses[1,1](53:7)/Address[0,inf](38:7)/Line2[1,1](15:7) /Collection[1,1](50:3)/Addresses[1,1](53:7)/Address[0,inf](38:7)/City[1,1](16:7) /Collection[1,1](50:3)/Addresses[1,1](53:7)/Address[0,inf](38:7)/State[1,1](17:7) /Collection[1,1](50:3)/Addresses[1,1](53:7)/Address[0,inf](38:7)/Zip[1,1](18:7) /Collection[1,1](50:3)/Addresses[1,1](53:7)/Address[0,inf](38:7)/ZipExt[1,1](19:7) /Collection[1,1](50:3)/Deliveries[1,1](54:7)/Delivery[0,inf](46:7)/Date[1,1](27:7) /Collection[1,1](50:3)/Deliveries[1,1](54:7)/Delivery[0,inf](46:7)/Time[1,1](28:7) /Collection[1,1](50:3)/Deliveries[1,1](54:7)/Delivery[0,inf](46:7)/Address[1,1](29:7) /Collection[1,1](50:3)/Deliveries[1,1](54:7)/Delivery[0,inf](46:7)/DeliveryID[1,1](30:7) /Collection[1,1](50:3)/Deliveries[1,1](54:7)/Delivery[0,inf](46:7)/Address[1,1](29:7)/Line1[1,1](14:7) /Collection[1,1](50:3)/Deliveries[1,1](54:7)/Delivery[0,inf](46:7)/Address[1,1](29:7)/Line2[1,1](15:7) /Collection[1,1](50:3)/Deliveries[1,1](54:7)/Delivery[0,inf](46:7)/Address[1,1](29:7)/City[1,1](16:7) /Collection[1,1](50:3)/Deliveries[1,1](54:7)/Delivery[0,inf](46:7)/Address[1,1](29:7)/State[1,1](17:7) /Collection[1,1](50:3)/Deliveries[1,1](54:7)/Delivery[0,inf](46:7)/Address[1,1](29:7)/Zip[1,1](18:7) /Collection[1,1](50:3)/Deliveries[1,1](54:7)/Delivery[0,inf](46:7)/Address[1,1](29:7)/ZipExt[1,1](19:7)