comp.lang.ada
 help / color / mirror / Atom feed
* Validating XML using Ada schema module
@ 2015-05-07 15:53 Sonia Dalal
  2015-05-07 15:58 ` Björn Lundin
  2015-05-08 10:20 ` Sonia Dalal
  0 siblings, 2 replies; 15+ messages in thread
From: Sonia Dalal @ 2015-05-07 15:53 UTC (permalink / raw)


Hi all

I am new to ada. I am working on a project where I am parsing XML for data. I am trying to validate the XML received (I am receiving XML from third party) using the schema module. Following is the sample schema which I took from w3c site after I was getting raised CONSTRAINT_ERROR : schema-validators.adb:2166 invalid data for my own schema but I am getting same error for this schema.

<?xml version="1.0"?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:element name="note">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="to" type="xs:string"/>
      <xs:element name="from" type="xs:string"/>
      <xs:element name="heading" type="xs:string"/>
      <xs:element name="body" type="xs:string"/>
    </xs:sequence>
  </xs:complexType>
</xs:element>

</xs:schema>

Changing the version and scheam tag to 
<?xml version="1.0" encoding="UTF-8"?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
targetNamespace="http://example.com/schemas/agent"
xmlns:agent="http://example.com/schemas/agent"> 

does not make any difference. I tried looking into schema-validators.adb but that was of no use. Please help.


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Validating XML using Ada schema module
  2015-05-07 15:53 Validating XML using Ada schema module Sonia Dalal
@ 2015-05-07 15:58 ` Björn Lundin
  2015-05-07 16:47   ` Simon Wright
  2015-05-08 10:20 ` Sonia Dalal
  1 sibling, 1 reply; 15+ messages in thread
From: Björn Lundin @ 2015-05-07 15:58 UTC (permalink / raw)


On 2015-05-07 17:53, Sonia Dalal wrote:

>I was getting raised CONSTRAINT_ERROR : schema-validators.adb:2166

I think you need to post your code.
Try to make a small compilable sample that reproduces your error
and post is here.



--
Björn

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Validating XML using Ada schema module
  2015-05-07 15:58 ` Björn Lundin
@ 2015-05-07 16:47   ` Simon Wright
  0 siblings, 0 replies; 15+ messages in thread
From: Simon Wright @ 2015-05-07 16:47 UTC (permalink / raw)


Björn Lundin <b.f.lundin@gmail.com> writes:

> On 2015-05-07 17:53, Sonia Dalal wrote:
>
>>I was getting raised CONSTRAINT_ERROR : schema-validators.adb:2166
>
> I think you need to post your code.
> Try to make a small compilable sample that reproduces your error
> and post is here.

Also, neither of the versions of XML/Ada that I have to hand has code at
that line which looks as though it could raise that exception at that
line. Which version are you using?

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Validating XML using Ada schema module
  2015-05-07 15:53 Validating XML using Ada schema module Sonia Dalal
  2015-05-07 15:58 ` Björn Lundin
@ 2015-05-08 10:20 ` Sonia Dalal
  2015-05-09 15:55   ` Björn Lundin
  1 sibling, 1 reply; 15+ messages in thread
From: Sonia Dalal @ 2015-05-08 10:20 UTC (permalink / raw)


On Thursday, May 7, 2015 at 9:23:22 PM UTC+5:30, Sonia Dalal wrote:
> Hi all
> 
> I am new to ada. I am working on a project where I am parsing XML for data. I am trying to validate the XML received (I am receiving XML from third party) using the schema module. Following is the sample schema which I took from w3c site after I was getting raised CONSTRAINT_ERROR : schema-validators.adb:2166 invalid data for my own schema but I am getting same error for this schema.
> 
> <?xml version="1.0"?>
> 
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
> 
> <xs:element name="note">
>   <xs:complexType>
>     <xs:sequence>
>       <xs:element name="to" type="xs:string"/>
>       <xs:element name="from" type="xs:string"/>
>       <xs:element name="heading" type="xs:string"/>
>       <xs:element name="body" type="xs:string"/>
>     </xs:sequence>
>   </xs:complexType>
> </xs:element>
> 
> </xs:schema>
> 
> Changing the version and scheam tag to 
> <?xml version="1.0" encoding="UTF-8"?>
> 
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> elementFormDefault="qualified"
> targetNamespace="http://example.com/schemas/agent"
> xmlns:agent="http://example.com/schemas/agent"> 
> 
> does not make any difference. I tried looking into schema-validators.adb but that was of no use. Please help.



The above code is what I have used in my xsd and I am following the Ada documentation to generate grammar. 
I have put my xsd code aside just to figure out what is the reason for error as it is same in both the scenarios.
I am using GNAT 4.6 so it should be Ada 2005.
Is it possible that it is due to some dependency or version clashes?


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Validating XML using Ada schema module
  2015-05-08 10:20 ` Sonia Dalal
@ 2015-05-09 15:55   ` Björn Lundin
  2015-05-09 16:49     ` Sonia Dalal
  0 siblings, 1 reply; 15+ messages in thread
From: Björn Lundin @ 2015-05-09 15:55 UTC (permalink / raw)


On 2015-05-08 12:20, Sonia Dalal wrote:

> The above code is what I have used in my xsd and I am following the Ada documentation to generate grammar.

You do not show the actual Ada code.

> I am using GNAT 4.6 so it should be Ada 2005.
> Is it possible that it is due to some dependency or version clashes?

Maybe - or it is your code. But since you don't show your code
it is impossible to tell...

--
Björn

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Validating XML using Ada schema module
  2015-05-09 15:55   ` Björn Lundin
@ 2015-05-09 16:49     ` Sonia Dalal
  2015-05-09 21:08       ` Björn Lundin
  0 siblings, 1 reply; 15+ messages in thread
From: Sonia Dalal @ 2015-05-09 16:49 UTC (permalink / raw)


On Saturday, May 9, 2015 at 9:24:29 PM UTC+5:30, björn lundin wrote:
> On 2015-05-08 12:20, Sonia Dalal wrote:
> 
> > The above code is what I have used in my xsd and I am following the Ada documentation to generate grammar.
> 
> You do not show the actual Ada code.
> 
> > I am using GNAT 4.6 so it should be Ada 2005.
> > Is it possible that it is due to some dependency or version clashes?
> 
> Maybe - or it is your code. But since you don't show your code
> it is impossible to tell...
> 
> --
> Björn


<?xml version="1.0"?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
---------------------------------This is the xsd file data---------------------
<xs:element name="note">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="to" type="xs:string"/>
      <xs:element name="from" type="xs:string"/>
      <xs:element name="heading" type="xs:string"/>
      <xs:element name="body" type="xs:string"/>
    </xs:sequence>
  </xs:complexType>
</xs:element>

</xs:schema>

-----------This is the file which is being used to generate grammar-------------

with Ada.Text_IO;   use Ada.Text_IO;
with Schema.Schema_Readers, Schema.Validators, Input_Sources.File;
use  Schema.Schema_Readers, Schema.Validators, Input_Sources.File;

procedure SchemaExample is
   Grammar : XML_Grammar;
   Schema  : Schema_Reader;
   Read    : File_Input;
begin
   Open ("pref.xsd", Read);
   Parse (Schema, Read);
   Close (Read);

   Grammar := Get_Grammar (Schema);

 exception
    when XML_Validation_Error =>
       Put_Line ("ERROR: " & Get_Error_Message (Schema));
end SchemaExample;


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Validating XML using Ada schema module
  2015-05-09 16:49     ` Sonia Dalal
@ 2015-05-09 21:08       ` Björn Lundin
  2015-05-10 18:16         ` Simon Wright
  2015-05-11 12:17         ` Sonia Dalal
  0 siblings, 2 replies; 15+ messages in thread
From: Björn Lundin @ 2015-05-09 21:08 UTC (permalink / raw)


On 2015-05-09 18:49, Sonia Dalal wrote:

using gpl2014_64 on debian 8 it behaves as
expected : it parses the xsd and exits with no error

I use XML/Ada GPL 2014 as well here.

So - the code itself is ok.

Platform ?
Your version of Xml/Ada ?

--
Björn

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Validating XML using Ada schema module
  2015-05-09 21:08       ` Björn Lundin
@ 2015-05-10 18:16         ` Simon Wright
  2015-05-11 12:17         ` Sonia Dalal
  1 sibling, 0 replies; 15+ messages in thread
From: Simon Wright @ 2015-05-10 18:16 UTC (permalink / raw)


Björn Lundin <b.f.lundin@gmail.com> writes:

> On 2015-05-09 18:49, Sonia Dalal wrote:
>
> using gpl2014_64 on debian 8 it behaves as
> expected : it parses the xsd and exits with no error
>
> I use XML/Ada GPL 2014 as well here.
>
> So - the code itself is ok.
>
> Platform ?
> Your version of Xml/Ada ?

GCC 4.6 sounds like debian wheezy.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Validating XML using Ada schema module
  2015-05-09 21:08       ` Björn Lundin
  2015-05-10 18:16         ` Simon Wright
@ 2015-05-11 12:17         ` Sonia Dalal
  2015-05-12 20:32           ` Björn Lundin
  1 sibling, 1 reply; 15+ messages in thread
From: Sonia Dalal @ 2015-05-11 12:17 UTC (permalink / raw)


On Sunday, May 10, 2015 at 2:37:26 AM UTC+5:30, björn lundin wrote:
> On 2015-05-09 18:49, Sonia Dalal wrote:
> 
> using gpl2014_64 on debian 8 it behaves as
> expected : it parses the xsd and exits with no error
> 
> I use XML/Ada GPL 2014 as well here.
> 
> So - the code itself is ok.
> 
> Platform ?
> Your version of Xml/Ada ?
> 
> --
> Björn

Simon is right its wheezy.
xmlada version is 3.2


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Validating XML using Ada schema module
  2015-05-11 12:17         ` Sonia Dalal
@ 2015-05-12 20:32           ` Björn Lundin
  2015-05-14  6:00             ` Sonia Dalal
  0 siblings, 1 reply; 15+ messages in thread
From: Björn Lundin @ 2015-05-12 20:32 UTC (permalink / raw)


On 2015-05-11 14:17, Sonia Dalal wrote:

> Simon is right its wheezy.
> xmlada version is 3.2
> 

I've got a couple of xml/ad versions
one is gpl 2014, the other I do not know - I think it
was bundled with a late-ish gnat pro.
One (gpl) points at function
   function Dump_Dot_NFA
for line 2166

the other points 1 row above
   function Get_Key
     (Group : XML_Group) return Unicode.CES.Byte_Sequence is


I think you need to show your line 2166. and the surounding lines.
and your link commands - and the gpr file.

I cannot really see anything wrong

-- 
--
Björn


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Validating XML using Ada schema module
  2015-05-12 20:32           ` Björn Lundin
@ 2015-05-14  6:00             ` Sonia Dalal
  2015-05-14 12:41               ` Björn Lundin
  0 siblings, 1 reply; 15+ messages in thread
From: Sonia Dalal @ 2015-05-14  6:00 UTC (permalink / raw)


On Wednesday, May 13, 2015 at 2:01:43 AM UTC+5:30, björn lundin wrote:
> On 2015-05-11 14:17, Sonia Dalal wrote:
> 
> > Simon is right its wheezy.
> > xmlada version is 3.2
> > 
> 
> I've got a couple of xml/ad versions
> one is gpl 2014, the other I do not know - I think it
> was bundled with a late-ish gnat pro.
> One (gpl) points at function
>    function Dump_Dot_NFA
> for line 2166
> 
> the other points 1 row above
>    function Get_Key
>      (Group : XML_Group) return Unicode.CES.Byte_Sequence is
> 
> 
> I think you need to show your line 2166. and the surounding lines.
> and your link commands - and the gpr file.
> 
> I cannot really see anything wrong
> 
> -- 
> --
> Björn

It is function Dump_Dot_NFA at line 2166.
I am using gnatmake filename.adb `xmlada-config` for linking.
I don't have any gpr file.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Validating XML using Ada schema module
  2015-05-14  6:00             ` Sonia Dalal
@ 2015-05-14 12:41               ` Björn Lundin
  2015-05-14 14:21                 ` Sonia Dalal
  0 siblings, 1 reply; 15+ messages in thread
From: Björn Lundin @ 2015-05-14 12:41 UTC (permalink / raw)


On 2015-05-14 08:00, Sonia Dalal wrote:
> On Wednesday, May 13, 2015 at 2:01:43 AM UTC+5:30, björn lundin wrote:
> It is function Dump_Dot_NFA at line 2166.
> I am using gnatmake filename.adb `xmlada-config` for linking.
> I don't have any gpr file.
> 

using that command and gnat gpl 2014 x64
work fine here.

I do have a gnat fsf 4.9, but I do not have a gnat fsf 4.6 anymore.

I'd try to install gnat gpl 2014 if it is possible.




-- 
--
Björn


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Validating XML using Ada schema module
  2015-05-14 12:41               ` Björn Lundin
@ 2015-05-14 14:21                 ` Sonia Dalal
  2015-05-14 15:06                   ` Sonia Dalal
  0 siblings, 1 reply; 15+ messages in thread
From: Sonia Dalal @ 2015-05-14 14:21 UTC (permalink / raw)


On Thursday, May 14, 2015 at 6:10:52 PM UTC+5:30, björn lundin wrote:
> On 2015-05-14 08:00, Sonia Dalal wrote:
> > On Wednesday, May 13, 2015 at 2:01:43 AM UTC+5:30, björn lundin wrote:
> > It is function Dump_Dot_NFA at line 2166.
> > I am using gnatmake filename.adb `xmlada-config` for linking.
> > I don't have any gpr file.
> > 
> 
> using that command and gnat gpl 2014 x64
> work fine here.
> 
> I do have a gnat fsf 4.9, but I do not have a gnat fsf 4.6 anymore.
> 
> I'd try to install gnat gpl 2014 if it is possible.
> 
> 
> 
> 
> -- 
> --
> Björn

I will try to install gnat fsf 4.9 and retry


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Validating XML using Ada schema module
  2015-05-14 14:21                 ` Sonia Dalal
@ 2015-05-14 15:06                   ` Sonia Dalal
  2015-05-14 15:56                     ` Björn Lundin
  0 siblings, 1 reply; 15+ messages in thread
From: Sonia Dalal @ 2015-05-14 15:06 UTC (permalink / raw)


On Thursday, May 14, 2015 at 7:51:19 PM UTC+5:30, Sonia Dalal wrote:
> On Thursday, May 14, 2015 at 6:10:52 PM UTC+5:30, björn lundin wrote:
> > On 2015-05-14 08:00, Sonia Dalal wrote:
> > > On Wednesday, May 13, 2015 at 2:01:43 AM UTC+5:30, björn lundin wrote:
> > > It is function Dump_Dot_NFA at line 2166.
> > > I am using gnatmake filename.adb `xmlada-config` for linking.
> > > I don't have any gpr file.
> > > 
> > 
> > using that command and gnat gpl 2014 x64
> > work fine here.
> > 
> > I do have a gnat fsf 4.9, but I do not have a gnat fsf 4.6 anymore.
> > 
> > I'd try to install gnat gpl 2014 if it is possible.
> > 
> > 
> > 
> > 
> > -- 
> > --
> > Björn
> 
> I will try to install gnat fsf 4.9 and retry

I cannot uninstall gnat. I have tried sudo apt-get remove gnat and sudo aptitude remove gnat gnat4.6. And due to this I cannot install gnat4.9 as it is conflicting with earlier version. How do I remove gnat4.6 so as to install 4.9?


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Validating XML using Ada schema module
  2015-05-14 15:06                   ` Sonia Dalal
@ 2015-05-14 15:56                     ` Björn Lundin
  0 siblings, 0 replies; 15+ messages in thread
From: Björn Lundin @ 2015-05-14 15:56 UTC (permalink / raw)


On 2015-05-14 17:06, Sonia Dalal wrote:
> On Thursday, May 14, 2015 at 7:51:19 PM UTC+5:30, Sonia Dalal wrote:
>> On Thursday, May 14, 2015 at 6:10:52 PM UTC+5:30, björn lundin wrote:
>>> On 2015-05-14 08:00, Sonia Dalal wrote:
>>>> On Wednesday, May 13, 2015 at 2:01:43 AM UTC+5:30, björn lundin wrote:
>>>> It is function Dump_Dot_NFA at line 2166.
>>>> I am using gnatmake filename.adb `xmlada-config` for linking.
>>>> I don't have any gpr file.
>>>>
>>>
>>> using that command and gnat gpl 2014 x64
>>> work fine here.
>>>
>>> I do have a gnat fsf 4.9, but I do not have a gnat fsf 4.6 anymore.
>>>
>>> I'd try to install gnat gpl 2014 if it is possible.
>>>
>>>
>>>
>>>
>>> -- 
>>> --
>>> Björn
>>
>> I will try to install gnat fsf 4.9 and retry
> 
> I cannot uninstall gnat. I have tried sudo apt-get remove gnat and sudo aptitude remove gnat gnat4.6. And due to this I cannot install gnat4.9 as it is conflicting with earlier version. How do I remove gnat4.6 so as to install 4.9?
> 


Note that I did not write that I got it to work with 4.9.
It should of course.

It seem like you have os-trouble.

 sudo apt-get remove gnat
 sudo apt-get install gnat-4.9

Should have done it, I think.

Another way is to install gnat gpl, and put it first in your path.
it is not a apt install, but a shell script, putting the compiler in
a directory of your choise. Easy to remove if you want to.




--
Björn

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2015-05-14 15:56 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-07 15:53 Validating XML using Ada schema module Sonia Dalal
2015-05-07 15:58 ` Björn Lundin
2015-05-07 16:47   ` Simon Wright
2015-05-08 10:20 ` Sonia Dalal
2015-05-09 15:55   ` Björn Lundin
2015-05-09 16:49     ` Sonia Dalal
2015-05-09 21:08       ` Björn Lundin
2015-05-10 18:16         ` Simon Wright
2015-05-11 12:17         ` Sonia Dalal
2015-05-12 20:32           ` Björn Lundin
2015-05-14  6:00             ` Sonia Dalal
2015-05-14 12:41               ` Björn Lundin
2015-05-14 14:21                 ` Sonia Dalal
2015-05-14 15:06                   ` Sonia Dalal
2015-05-14 15:56                     ` Björn Lundin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox