[Mono-list] Problems using RelaxngValidatingReader (c#)
Atsushi Eno
atsushieno at veritas-vos-liberabit.com
Thu Oct 23 23:19:10 UTC 2014
Phew, there was a bug! It was about handling default namespace. I fixed
it in master.
https://github.com/mono/mono/commit/3d9a2b7
Until you get the fixed version, a workaround is to put explicit
declaration on top:
default namespace = ""
Atsushi Eno
On 2014年10月24日 06:14, Jesper Lund Stocholm wrote:
> Hi Atsushi,
>
> Thank you for your reply.
>
> I finally got it to work.
>
> Now, I have tried to do make an RNC-equivalent to the RNG-schema I made. The RNC-schemas is this:
>
> element library
> {
> element book
> {
> attribute id {xsd:ID},
> attribute available {xsd:boolean},
> element isbn {token - "12345"},
> element title {attribute xml:lang {xsd:language}, xsd:token},
> element year {xsd:integer}
> }+
> }
>
> As far as I can see, it /should/ validate XML like this:
>
> <?xml version="1.0" encoding="utf-8"?>
> <library>
> <book id="b0836217462" available="true">
> <isbn>37474739292</isbn>
> <title xml:lang="en">Being a Dog Is a Full-Time Job</title>
> <year>2014</year>
> </book>
> <book id="b0836wew217462" available="false">
> <isbn>1234</isbn>
> <title xml:lang="en">Relax NG - a simpler schema language for XML</title>
> <year>2020</year>
> </book>
> </library>
>
> But I cannot get past an exception saying that
>
> Commons.Xml.Relaxng.RelaxngException: Invalid start tag closing found. LocalName
> = library, NS = .file:///C:/projects/monodemo/MonoDemo/bin/Debug/bookstore.xml
> line 2, column 2
>
>
> Is the answer to this as simple as the reply you gave me earlier ... and am I missing something completely obvious?
>
> Project available here: https://bitbucket.org/jlundstocholm/monodemo/src/1d1b2e1eeeb50f87aa3f6a3bfa6a6366d96f4e74?at=master
>
> :o)
>
> Jesper Lund Stocholm
>
>
>
>
>
>
>
> -----Original Message-----
> From: Atsushi Eno [mailto:atsushieno at veritas-vos-liberabit.com]
> Sent: 23. oktober 2014 17:14
> To: Jesper Lund Stocholm; mono-list at lists.ximian.com
> Subject: Re: [Mono-list] Problems using RelaxngValidatingReader (c#)
>
> Hello,
>
> An <element> has to contain one ore more pattern, https://www.oasis-open.org/committees/relax-ng/spec.html#full-syntax
>
> which is missing in your <element name='book'></element>.
> Specify <empty/> there.
>
> Atsushi Eno
>
> On 2014年10月21日 15:15, Jesper Lund Stocholm wrote:
>> I am trying to use the RelaxngValidatingReader (located at mcs/class/Commons.Xml.Relaxng/ ) but I am getting errors that I cannot understand.
>>
>> (if this is the wrong list, please let me know the correct one - I
>> couldn't find a better match)
>>
>> I have made a simple C# console application in Visual Studio - I am
>> using sample data from the Relax NG book by Eric van der Vlist)
>>
>> My code is this:
>>
>> var rngPattern = Encoding.UTF8.GetBytes(
>>
>> @"
>> <element name='library' xmlns='http://relaxng.org/ns/structure/1.0'>
>> <oneOrMore>
>> <element name='book'></element>
>> </oneOrMore>
>> </element>"
>> );
>>
>> var stream = new MemoryStream(rngPattern);
>>
>> stream.Position = 0;
>> var xmlReader = XmlReader.Create(stream); var pattern0 =
>> RelaxngPattern.Read(xmlReader);
>>
>> My Xml is this:
>>
>> <?xml version="1.0" encoding="utf-8"?> <library
>> xmlns="http://tempuri.org">
>> <book id="b0836217462" available="true">
>> <isbn>37474739292</isbn>
>> <title xml:lang="en">Being a Dog Is a Full-Time Job</title>
>> <author id="CMS"></author>
>> <character id="PP"></character>
>> <character id="Snoopy"></character>
>> <character id="Schroeder"></character>
>> <character id="Lucy"></character>
>> </book>
>> </library>
>>
>> But whenever I get to the last line in my code, an exception is thrown :
>>
>> Commons.Xml.Relaxng.RelaxngException: RELAX NG pattern did not appear.
>>
>>
>> Can you help me closer to the cause of this? Is it a namespace issue?
>>
>>
>>
>>
>> Med venlig hilsen / Best regards
>>
>> Jesper Lund Stocholm
>> mailto:jesper.stocholm at ciber.com
>> www.ciber.com
>>
>>
>>
>>
>>
>>
>>
>> _______________________________________________
>> Mono-list maillist - Mono-list at lists.ximian.com
>> http://lists.ximian.com/mailman/listinfo/mono-list
>>
>>
>>
> _______________________________________________
> Mono-list maillist - Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
More information about the Mono-list
mailing list