From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,d4ae576545d491bc X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit X-Received: by 10.180.106.73 with SMTP id gs9mr3645314wib.2.1366082665520; Mon, 15 Apr 2013 20:24:25 -0700 (PDT) Path: hg5ni6325wib.1!nntp.google.com!feeder1.cambriumusenet.nl!feed.tweaknews.nl!194.109.133.81.MISMATCH!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!border4.nntp.ams.giganews.com!border2.nntp.ams.giganews.com!nntp.giganews.com!news.teledata-fn.de!weretis.net!feeder4.news.weretis.net!nuzba.szn.dk!pnx.dk!eternal-september.org!feeder.eternal-september.org!mx05.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: XML/Ada schema validation and XML namespaces Date: Tue, 09 Apr 2013 12:45:20 +0100 Organization: A noiseless patient Spider Message-ID: References: Mime-Version: 1.0 Injection-Info: mx05.eternal-september.org; posting-host="759faf2487b2ffad9ca6f5463a606de4"; logging-data="28137"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX193KOwtPl8ySz/J2hwV2WhoQ2Z0h36wt9k=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (darwin) Cancel-Lock: sha1:611xLUXsQZ0Thq4N4SlifGI6Bl8= sha1:a99JaeliFBSfdcrVs3YH2olHQ+E= Content-Type: text/plain Date: 2013-04-09T12:45:20+01:00 List-Id: J Kimball writes: > I'm having the derndest time figuring out how to validate XML using > namespaces against a schema with XML/Ada. I seem to recall that doing > away with namespaces makes it work. After all the debug junk I don't > care about scrolls past, I see: > > Validation_Error: Attribute "xmlns:agent" invalid for type > {http://singo1.com/schemas/agent}agent-message > Exception name: SCHEMA.VALIDATORS.XML_VALIDATION_ERROR > > it seems like an issue with XML/Ada. Can you tell me if I'm missing a > feature to enable, something about XML that I'm missing or just wrong > code or an example that is using namespaces that works? I think you may have been using the AdaCore documentation at [1]? If so, I think the problem is that the examples in 6.4, 6.5 don't actually set the grammar to be used by the reader; in 6.3 there's a declare block which shows you how to do it, eg with Sax.Readers; use Sax.Readers; with Schema.Readers; use Schema.Readers; with Schema.Schema_Readers; use Schema.Schema_Readers; with Schema.Validators; use Schema.Validators; with Input_Sources.File; use Input_Sources.File; with Ada.Text_IO; use Ada.Text_IO; procedure SchemaExample is Grammar : XML_Grammar; Schema : Schema_Reader; Input : File_Input; My_Reader : Validating_Reader; begin Open ("agent.xsd", Input); Parse (Schema, Input); Close (Input); Grammar := Get_Grammar (Schema); Set_Public_Id (Input, "Agent file"); Open ("agent.xml", Input); Set_Grammar (My_Reader, Grammar); Set_Feature (My_Reader, Schema_Validation_Feature, True); Parse (My_Reader, Input); Close (Input); Put_Line ("OK."); end SchemaExample; which outputs "OK.". I'm about to report this problem to AdaCore. [1] http://docs.adacore.com/xmlada-docs/schema.html