Return-Path: Delivered-To: apmail-xerces-c-users-archive@www.apache.org Received: (qmail 65931 invoked from network); 22 Jul 2008 18:50:44 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 22 Jul 2008 18:50:44 -0000 Received: (qmail 42080 invoked by uid 500); 22 Jul 2008 18:50:42 -0000 Delivered-To: apmail-xerces-c-users-archive@xerces.apache.org Received: (qmail 42064 invoked by uid 500); 22 Jul 2008 18:50:42 -0000 Mailing-List: contact c-users-help@xerces.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: c-users@xerces.apache.org Delivered-To: mailing list c-users@xerces.apache.org Received: (qmail 42053 invoked by uid 99); 22 Jul 2008 18:50:42 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 22 Jul 2008 11:50:42 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [155.212.198.117] (HELO mail.pingtel.com) (155.212.198.117) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 22 Jul 2008 18:49:46 +0000 Received: from [127.0.0.1] (ssh.pingtel.com [10.1.20.8]) by mail.pingtel.com (Postfix) with ESMTP id A83106C017 for ; Tue, 22 Jul 2008 14:49:38 -0400 (EDT) Subject: Specifying the location of .xsd files to use when validating an XML file From: Dale Worley To: c-users@xerces.apache.org Content-Type: text/plain Date: Tue, 22 Jul 2008 14:49:38 -0400 Message-Id: <1216752578.4541.46.camel@victoria.pingtel.com> Mime-Version: 1.0 X-Mailer: Evolution 2.12.3 (2.12.3-5.fc8) Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org This is another version of a question which seems to come up perennially, but it seems to be slightly different than the versions I can find discussion of. I am using Xerces-C to validate an XML file. The file uses a namespace, but does not describe where to find the schema (.xsd file) for the namespace. So before validating the file, I call fgXercesSchemaExternalSchemaLocation to give the names of the files containing the schemas for the namespaces that the XML file might use. So far, that works fine: Xerces locates the schema for the namespace that the XML file uses. The difficulty is that one of the schemas imports another schema. Xerces seems to demand that the first schema contain an element, and that the provide the file name containing the imported schema; the list provided to fgXercesSchemaExternalSchemaLocation seems to have no effect. Whereas I would assume that the fgXercesSchemaExternalSchemaLocation list would be consulted first to find the imported namespace, and the schemaLocation attribute of the element would be ignored. In particular, section 4.2.3 of XML Schema Part 1 suggests that omitting the schemaLocation attribute is intended to leave it to the processor to determine how the find the schema, and in the context of Xerces, I would expect Xerces to consult the fgXercesSchemaExternalSchemaLocation list. But if I omit schemaLocation, I get errors like this: Error at file file:///home/dworley/sandbox-151/dir-local/share/sipxecs/schema/alias.xsd, line 54, char 54 Message: Schema Representation Constraint: Namespace 'http://www.sipfoundry.org/sipX/schema/xml/sip-00-01' is referenced without declaration And note that the message is factually incorrect; there is an element: Dale