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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,94cb515ac93c798b,start X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!n13g2000vbv.googlegroups.com!not-for-mail From: =?ISO-8859-1?Q?bj=F6rn_lundin?= Newsgroups: comp.lang.ada Subject: xmlada validate schema trickery Date: Fri, 14 Oct 2011 07:19:26 -0700 (PDT) Organization: http://groups.google.com Message-ID: <4b1a5483-d905-40be-b3a2-660a95a4d2a0@n13g2000vbv.googlegroups.com> NNTP-Posting-Host: 83.145.50.10 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1318601967 10366 127.0.0.1 (14 Oct 2011 14:19:27 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 14 Oct 2011 14:19:27 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: n13g2000vbv.googlegroups.com; posting-host=83.145.50.10; posting-account=3_reEwoAAAC163IAIrx427KYmwahFuh9 User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: HUALESNKRC X-HTTP-UserAgent: Mozilla/5.0 (Windows NT 5.1; rv:7.0.1) Gecko/20100101 Firefox/7.0.1,gzip(gfe) Xref: g2news1.google.com comp.lang.ada:21434 Date: 2011-10-14T07:19:26-07:00 List-Id: Hi! I'm using xmlada to validate some xmlfiles, and it works well. function Validate(Xml, Xsd : in String) return Boolean is Explicit_XSD : Boolean :=3D False; Read : File_Input; Schema : Schema_Reader; Grammar : XML_Grammar :=3D No_Grammar; My_Reader : Validating_Reader; begin if Xsd'length > 0 then if Ada.Directories.Exists(Xsd) then begin Open (Xsd, Read); Parse (Schema, Read); Close (Read); Explicit_XSD :=3D True; exception when XML_Validation_Error =3D> Close (Read); raise; end; else Feedback("File '" & Xsd & "' does not exist"); return False; end if; end if; if Ada.Directories.Exists(Xml) then if Explicit_XSD then Grammar :=3D Get_Created_Grammar(Schema); Global_Check (Grammar); end if; xmlns=3D"http://www.consafelogistics.com/sattmate" Set_Validating_Grammar(My_Reader, Grammar); Set_Feature(My_Reader, Schema_Validation_Feature, True); Open(Xml, Read); Parse(My_Reader, Read); Close(Read); Feedback("File '" & Xml & "' is valid"); return True; else Feedback("File '" & Xml & "' does not exist"); return False; end if; exception when E : XML_Validation_Error | XML_Fatal_Error =3D> Feedback(Exception_Message (E)); Close(Read); return False; when Ada.Io_Exceptions.Name_Error =3D> Feedback("File '" & Xml & "' is not a valid filename"); return False; end Validate; ---------------------------------------- this is called by if Is_Set(Xsd) then if Validate(Xml =3D> Parameter(1), Xsd =3D> Value(Xsd)) then Set_Exit_Status(Success); end if; else if Validate(Xml =3D> Parameter(1), Xsd =3D> "") then Set_Exit_Status(Success); end if; end if; where Value(Xsd)) holds xsd filename and Parameter(1) holds xml filename xml looks like and xsd This works well :-) However, the xmlfiles are processed by some tcl-scripts as well, and the (bad) tcldom(2.6) implementation (which I cannot upgrade) crashes on the xmlns attribute So I remove that so the xml looks like but then I get an error: Element "goal": No matching declaration available So, Im looking for a way to trick the parser to believe that the xmlns=3D"http://www.abc.com/some_namespace" attribute is there, thus keeping me, tcl, and xmlada happy Any suggestions? /Bj=F6rn