I've got this unit test, which works fine (the input is a document with multiple entities):

public void testValidationWithEntities() {
        try {
            Processor proc = new Processor(true);
            DocumentBuilder builder = proc.newDocumentBuilder();
            XdmNode doc = builder.build(new File(ConfigTest.DATA_DIR + "book-wrapper.xml"));

            SchemaManager mgr = proc.getSchemaManager();
            mgr.load(new StreamSource(new File(ConfigTest.DATA_DIR + "books.xsd")));
            SchemaValidator v = mgr.newSchemaValidator();
            XdmDestination dest = new XdmDestination();
            v.setDestination(dest);
            v.validate(doc.asSource());

            XdmNode validDoc = dest.getXdmNode();
            Set baseUris = new HashSet();
            XdmSequenceIterator iter = validDoc.axisIterator(Axis.DESCENDANT);
            while (iter.hasNext()) {
                XdmNode node = (XdmNode)iter.next();
                if (node.getNodeKind() == XdmNodeKind.ELEMENT) {
                    baseUris.add(node.getBaseURI());
                }
            }
            assertTrue("3 distinct base URIs", baseUris.size() == 3);
            assertTrue("doc base URI", doc.getBaseURI().toString().endsWith("book-wrapper.xml"));

        } catch (SaxonApiException sapie) {
           sapie.printStackTrace();
           fail(sapie.getMessage());
        }
        catch (Exception e) {
            e.printStackTrace();
            fail(e.getMessage());
        }
    }

This seems pretty close to what you are doing. Can you show a specific test that fails?

Michael Kay
Saxonica


On 22/03/2013 12:34, Norman Walsh wrote:
Norman Walsh <ndw@nwalsh.com> writes:
Michael Kay <mike@saxonica.com> writes:
I guess it depends on what interface you use to "run it through the validator".
I'm calling the S9API's SchemaValidator.validate(node.asSource()).
Would you expect this to work?

I know there are some paths through the validator that work hard to
preserve base URIs even when they change in mid-document (at entity
boundaries), but it wouldn't surprise me if there are other paths
that don't (and APIs that place their own requirements).
I'm happy to call the validator a different way if you have a
suggestion...
                                        Be seeing you,
                                          norm



------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar


_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/saxon-help