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 4: //*
public static List<PathElement> example4(SchemaData schData) { XPath xpath = new XPath("//*"); // analyse XPath List<PathElement> matched = null; try { matched = xpath.analyse(schData, null); } catch (XPathException e) { System.err.println(e.getMessage()); } // print matched nodes printMatchedNodes(matched); return matched; }
Output
Matched nodes: /Address[1,1](10:3) /Delivery[1,1](23:3) /Addresses[1,1](34:3) /Deliveries[1,1](42:3) /Collection[1,1](50:3) /ID[1,1](58:3) /Address[1,1](10:3)/Line1[1,1](14:7) /Address[1,1](10:3)/Line2[1,1](15:7) /Address[1,1](10:3)/City[1,1](16:7) /Address[1,1](10:3)/State[1,1](17:7) /Address[1,1](10:3)/Zip[1,1](18:7) /Address[1,1](10:3)/ZipExt[1,1](19:7) /Delivery[1,1](23:3)/Date[1,1](27:7) /Delivery[1,1](23:3)/Time[1,1](28:7) /Delivery[1,1](23:3)/Address[1,1](29:7) /Delivery[1,1](23:3)/DeliveryID[1,1](30:7) /Addresses[1,1](34:3)/Address[0,inf](38:7) /Deliveries[1,1](42:3)/Delivery[0,inf](46:7) /Collection[1,1](50:3)/Addresses[1,1](53:7) /Collection[1,1](50:3)/Deliveries[1,1](54:7) /Delivery[1,1](23:3)/Address[1,1](29:7)/Line1[1,1](14:7) /Delivery[1,1](23:3)/Address[1,1](29:7)/Line2[1,1](15:7) /Delivery[1,1](23:3)/Address[1,1](29:7)/City[1,1](16:7) /Delivery[1,1](23:3)/Address[1,1](29:7)/State[1,1](17:7) /Delivery[1,1](23:3)/Address[1,1](29:7)/Zip[1,1](18:7) /Delivery[1,1](23:3)/Address[1,1](29:7)/ZipExt[1,1](19:7) /Addresses[1,1](34:3)/Address[0,inf](38:7)/Line1[1,1](14:7) /Addresses[1,1](34:3)/Address[0,inf](38:7)/Line2[1,1](15:7) /Addresses[1,1](34:3)/Address[0,inf](38:7)/City[1,1](16:7) /Addresses[1,1](34:3)/Address[0,inf](38:7)/State[1,1](17:7) /Addresses[1,1](34:3)/Address[0,inf](38:7)/Zip[1,1](18:7) /Addresses[1,1](34:3)/Address[0,inf](38:7)/ZipExt[1,1](19:7) /Deliveries[1,1](42:3)/Delivery[0,inf](46:7)/Date[1,1](27:7) /Deliveries[1,1](42:3)/Delivery[0,inf](46:7)/Time[1,1](28:7) /Deliveries[1,1](42:3)/Delivery[0,inf](46:7)/Address[1,1](29:7) /Deliveries[1,1](42:3)/Delivery[0,inf](46:7)/DeliveryID[1,1](30: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) /Deliveries[1,1](42:3)/Delivery[0,inf](46:7)/Address[1,1](29:7)/Line1[1,1](14:7) /Deliveries[1,1](42:3)/Delivery[0,inf](46:7)/Address[1,1](29:7)/Line2[1,1](15:7) /Deliveries[1,1](42:3)/Delivery[0,inf](46:7)/Address[1,1](29:7)/City[1,1](16:7) /Deliveries[1,1](42:3)/Delivery[0,inf](46:7)/Address[1,1](29:7)/State[1,1](17:7) /Deliveries[1,1](42:3)/Delivery[0,inf](46:7)/Address[1,1](29:7)/Zip[1,1](18:7) /Deliveries[1,1](42:3)/Delivery[0,inf](46:7)/Address[1,1](29:7)/ZipExt[1,1](19: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)