From: Simon Wright <simon@pushface.org>
Subject: Re: XML/Ada schema validation and XML namespaces
Date: Tue, 09 Apr 2013 12:45:20 +0100
Date: 2013-04-09T12:45:20+01:00 [thread overview]
Message-ID: <lytxngexm7.fsf@pushface.org> (raw)
In-Reply-To: kjv7i1$flb$1@hugin.sparre-andersen.dk
J Kimball <nntp@kmbll.com> 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
next prev parent reply other threads:[~2013-04-09 11:45 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-08 19:58 XML/Ada schema validation and XML namespaces J Kimball
2013-04-08 20:00 ` J Kimball
2013-04-09 11:45 ` Simon Wright [this message]
2013-04-10 17:42 ` J Kimball
2013-04-10 19:56 ` Simon Wright
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox