How can I get the xml Node type based on schema definition in Java?
Let's say I have a doc.xml and corresponding doc.xsd. I use xpath to retrieve some nodes, so I get a list of org.w3c.dom.Node. How can I get type of each node from schema, eg. xs:integer, xs:string etc ?

Some solution would be to parse schema with xpath query "//NodeName[@type]" using node.getNodeName() as NodeName, but that's not perfect. I can't be sure that schema is elegant - what if NodeName exists in many places in schema and has not been extracted as a separate type?

So generally I am looking for a reliable solution to get the node type for ANY valid xml & xsd.
 
How can I get the xml Node type based on schema definition in Java?
===

Let's say I have a doc.xml and corresponding doc.xsd. I use xpath to retrieve some nodes, so I get a list of org.w3c.dom.Node. How can I get type of each node from schema, eg. xs:integer, xs:string etc ?

Some solution would be to parse schema with xpath query "//NodeName[@type]" using node.getNodeName() as NodeName, but that's not perfect. I can't be sure that schema is elegant - what if NodeName exists in many places in schema and has not been extracted as a separate type?

So generally I am looking for a reliable solution to get the node type for ANY valid xml & xsd.
 