Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > How do I express this constraint with RELAX NG?

Reply
Thread Tools

How do I express this constraint with RELAX NG?

 
 
James McComb
Guest
Posts: n/a
 
      11-19-2003
Please, can someone tell me how I can express
this constraint using Relax NG?

I want these documents to be valid:

<memo>
<code>WithMessage</code>
<message>WithMessage means there is a message.</message>
</memo>

<memo>
<code>WithoutMessage</code>
<!-- WithoutMessage so no message -->
</memo>

And these documents to be invalid:

<memo>
<code>WithoutMessage</code>
<message>This element shouldn't exist.</message>
</memo>

<memo>
<code>WithMessage</code>
<!-- There should be a message here -->
</memo>

Thanks.

James McComb
 
Reply With Quote
 
 
 
 
Bob Foster
Guest
Posts: n/a
 
      11-20-2003
Like this:

<grammar xmlns="http://relaxng.org/ns/structure/1.0">
<start>
<element name="memo">
<choice>
<group>
<element name="code">
<value>WithMessage</value>
</element>
<element name="message">
<text/>
</element>
</group>
<element name="code">
<value>WithoutMessage</value>
</element>
</choice>
</element>
</start>
</grammar>

Bob Foster

"James McComb" <> wrote in message
news: om...
> Please, can someone tell me how I can express
> this constraint using Relax NG?
>
> I want these documents to be valid:
>
> <memo>
> <code>WithMessage</code>
> <message>WithMessage means there is a message.</message>
> </memo>
>
> <memo>
> <code>WithoutMessage</code>
> <!-- WithoutMessage so no message -->
> </memo>
>
> And these documents to be invalid:
>
> <memo>
> <code>WithoutMessage</code>
> <message>This element shouldn't exist.</message>
> </memo>
>
> <memo>
> <code>WithMessage</code>
> <!-- There should be a message here -->
> </memo>
>
> Thanks.
>
> James McComb



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re-using a simple type definition; with enumeration constraint andwithout enumeration constraint puvit82 XML 4 02-01-2008 03:46 PM
RELAX NG text constraint Geert XML 0 12-04-2004 02:49 PM
relax and believe bigtip MCSE 79 12-24-2003 03:20 PM
Motivation for using either Relax NG or W3C XML Schema Pieter XML 6 11-28-2003 09:51 AM
Beginner's problem when using jing Relax NG validator through JARVinterface Jari Kujansuu XML 0 09-04-2003 02:49 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57