Hi Mukul, Thanks for your answer; this would be an option indeed.
The background of my question is that we would like to improve catalog resolutions in the open source DBMS BaseX, which provides XQuery functions for validating documents via Xerces and Saxon. Catalogs can be used for document parsing and and XSL transformations, but I haven’t managed yet to get this working for validations. Maybe it’s simply not possible with Xerces what I want to achieve? Or maybe I should ask somewhere else? Cheers, Christian Mukul Gandhi <muk...@apache.org> schrieb am Di., 26. Nov. 2019, 12:06: > Hi Christian, > I'm not an expert on XMLCatalogResolver. > > But following solution comes to my mind for your use case, using a > different approach, > You could precede the schema validation, with an XSLT transform (using an > identity transform like XSLT stylesheet) that converts "http" URLs into > "https" URLs present in the schema. You could additionally join these two > steps with something like a batch file. > > On Tue, Nov 26, 2019 at 3:59 PM Christian Grün <christian.gr...@gmail.com> > wrote: > >> Anyone who could give me some hints here? >> >> >> On Mon, Nov 11, 2019 at 12:15 PM Christian Grün >> <christian.gr...@gmail.com> wrote: >> > >> > Hi all, >> > >> > I’m trying to validate a document with Xerces. My schema has "http" >> includes that need to be rewritten to "https". I try to do this with an XML >> catalog and rewriteURI, but the rule seems to be ignored. >> > >> > I have attached some stripped-down Java code. The inclusion of " >> http://standards.iso.org/..." leads to a "Premature end of file" >> exception (presumably because the request returns a 302 redirect with an >> empty payload). Another (expected) error is raised if the URL is changed to >> https. >> > >> > My questions: >> > >> > • (Why) Is the rewriteURI rule ignored? >> > • How can I enable some debugging output, or adjust the verbosity >> level, with the XMLCatalogResolver? >> > >> > I managed to get the validation running with Saxon EE. >> > >> > Thanks in advance, >> > Christian >> > ________________________________ >> > >> > import java.nio.file.*; >> > import javax.xml.validation.*; >> > import org.apache.xerces.jaxp.validation.*; >> > import org.apache.xerces.util.*; >> > >> > public class ValidateTest { >> > public static void main(final String... args) throws Exception { >> > String schemaString = >> > "<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'>" + >> > " <xs:include schemaLocation='" + >> > " >> https://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/gmd/gmd.xsd'/>" >> + >> > "</xs:schema>"; >> > String catalogString = >> > "<catalog xmlns='urn:oasis:names:tc:entity:xmlns:xml:catalog'>" >> + >> > " <rewriteURI uriStartString='http://standards.iso.org'" + >> > " rewritePrefix='https://standards.iso.org'/>" + >> > "</catalog>"; >> > >> > String dir = System.getProperty("java.io.tmpdir") + '/'; >> > Path schema = Paths.get(dir + "schema.xsd"); >> > Files.write(schema, schemaString.getBytes()); >> > Path catalog = Paths.get(dir + "catalog.xml"); >> > Files.write(catalog, catalogString.getBytes()); >> > >> > SchemaFactory sf = new XMLSchema11Factory(); >> > XMLCatalogResolver r = new XMLCatalogResolver(new String[] { >> catalog.toUri().toString() }); >> > sf.setResourceResolver(r); >> > sf.newSchema(schema.toFile()); >> > } >> > } >> > > > > > -- > Regards, > Mukul Gandhi >