473,465 Members | 2,092 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How do I express this constraint with RELAX NG?

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
Jul 20 '05 #1
1 1374
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" <ja***@heart.com.au> wrote in message
news:42**************************@posting.google.c 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

Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Pieter | last post by:
I've read a lot of posts on "why relax ng is so very good" and on "why w3c xml schema should be the only schema language". I'm, however, still not clear on why I should prefer one over the other. ...
5
by: Ralf Wahner | last post by:
Dear Masters of XML As I'm new to XML Schema I dare to ask a possibly recurring question: Given an element <elem> with two attributes @a and @b. The attributes are bound by the condition, that...
0
by: Geert | last post by:
Hello, I'm trying to write a RELAX NG schema that *only* validates the following XML instance (with mixed content): <div id="1">A<a href="X"/></div> The problem is to constrain the text...
4
by: withtape | last post by:
Somebody please, please help me. I'm getting started using Relax NG to describe document schemas. After reading the grammar summarized by http://www.relaxng.org/spec-20011203.html (Section 5), I...
3
by: Rico | last post by:
Hello, I have a foreign key constraint between two tables (Appointments and MissedAppointmentReasons) and I'd like to allow null values in Appointments table for the field containing the...
9
by: HC | last post by:
Hello, all, I started out thinking my problems were elsewhere but as I have worked through this I have isolated my problem, currently, as a difference between MSDE and SQL Express 2005 (I'll just...
1
by: Spectre1337 | last post by:
Hello, it seems like the check constraint validation of MS SQL Server Management Studio express is horribly, horribly broken. Either that or I'm using it wrong. I hope it's the latter. I'm...
5
by: Fenix Bird | last post by:
Hello... I'm new to MS SQL, so please be nice... LOLOL I decided to go from Access 2003 with the MS SQL Express Edition (I really don't need all the features of the full version, if so, I can...
21
by: James | last post by:
http://www.microsoft.com/express/download/ I've just seen the ad and the download page. 1) what are you missing if you use these as opposed to full version of Visual Studio? 2) can you...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.