Hello Michael,

probably not Saxon's fault, but I report it because the problem might be of interest to others, and perhaps you recommend a workaround.

When validating a document using javax.xml.validation, one cannot supply an XdmNode as a Source object (obtained by XdmNode.asSource()).
Indeed, the Javadoc of "asSouce" states: "However, there is no guarantee that it will be recognized by other products."

What would you suggest to do if one has schema and/or instance document available as XdmNode and wants to use javax.xml.validation? Transform it to DOM (as I suppose), or serialize, or yet something else? Using S9API, the scenario is very common, so a best practise recommendation would be appreciated.

Thank you,
-- Hans-Jürgen


PS: Example code:
======
XdmNode schema = ...;
XdmNode doc = ...;
validateXml(doc.asSource(), schema.asSource());

static public void validateXml(Source xmlSource, Source schemaSource) throws X4JException {
try {
   SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
   Schema schema = factory.newSchema(schemaSource);
   schema.newValidator().validate(xmlSource);
} catch (SAXException e) {...
======

Both, "schemaSource" and "xmlSource" in this code are rejected. Error message:
java.lang.IllegalArgumentException: Source parameter of type 'net.sf.saxon.tree.tiny.TinyElementImpl' is not accepted by this validator.