Suppose that...
- I have a complex XML schema, one that imports/includes other schema files, which in turn import/include even more schema files.
- I want to find all the elements in this XML schema that have a value (i.e., text node) that is declared to be of type QName.
- I want the location (path) of these elements to be expressed as XPath statements (e.g., /foo/bar).
If I'm writing a Java application, what's the right technology for this job? Is it a schema object model like XSOM? Is it the Java XPath API? Something else?
Edit: For those who want a jumpstart on accessing the SCM in Saxon (per Michael Kay's recommendation below), here's some Java code (sans exception handling):
// Load the XSD into Saxon
Processor processor = new Processor(true);
SchemaManager schemaManager = processor.getSchemaManager();
DocumentBuilder documentBuilder = processor.newDocumentBuilder();
SAXSource saxSource = new SAXSource(new InputSource("path/to/yourSchema.xsd"));
XdmNode schema = documentBuilder.build(saxSource);
schemaManager.load(saxSource);
// Export the SCM
XdmDestination destination = new XdmDestination();
schemaManager.exportComponents(destination);
XdmNode xdmNode = destination.getXdmNode();
System.out.println(xdmNode.toString());