Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Possible with schema?

Reply
Thread Tools

Possible with schema?

 
 
Lord0
Guest
Posts: n/a
 
      02-23-2007
Is it possible to validate/check for the following using a schema?

<question answer="yes">
<answer>This is the answer</answer>
</question>

OR

<question answer="no" />

Where "question" can change.....i.e.

The schema fragment which *would* validate this:

<question1 answer="yes">
<answer>This is the answer</answer>
</question1>

OR

<question1 answer="no" />

Would also be able to validate this:

<question2 answer="yes">
<answer>This is the answer</answer>
</question2>

OR

<question2 answer="no" />

WITHOUT hardcoding "question1", "question2" etc in the schema

Maybe Im going Friday afternoon mad!

Cheers

Lord0

 
Reply With Quote
 
 
 
 
Joseph Kesselman
Guest
Posts: n/a
 
      02-23-2007
Redesign as <question number="2" ....>.

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
 
Reply With Quote
 
 
 
 
Lord0
Guest
Posts: n/a
 
      02-23-2007
On 23 Feb, 15:37, Joseph Kesselman <(E-Mail Removed)> wrote:
> Redesign as <question number="2" ....>.
>
> --
> Joe Kesselman / Beware the fury of a patient man. -- John Dryden


Hmm, I got as far as.......

<choice>
<element name="question" type="this:noAttributeType" />
<element name="question"
type="this:yesAttributeWithDescriptionType" />
</choice>

<complexType name="noAttributeType">
<attribute name="value" type="string" fixed="no" use="required"/>
<attribute name="number" type="nonNegativeInteger" use="required"/
>

</complexType>

<complexType name="yesAttributeWithDescriptionType">
<sequence>
<element name="description" type="string" />
</sequence>
<attribute name="value" type="string" fixed="no" use="required"/>
<attribute name="number" type="nonNegativeInteger" use="required"/
>

</complexType>

but of course I get "Unique Particle Attribution" violation.

 
Reply With Quote
 
Lord0
Guest
Posts: n/a
 
      02-23-2007
Sorry about formatting above ^^

 
Reply With Quote
 
usenet@tech-know-ware.com
Guest
Posts: n/a
 
      02-23-2007
On 23 Feb, 15:45, "Lord0" <(E-Mail Removed)> wrote:
> On 23 Feb, 15:37, Joseph Kesselman <(E-Mail Removed)> wrote:
>
> > Redesign as <question number="2" ....>.

>
> > --
> > Joe Kesselman / Beware the fury of a patient man. -- John Dryden

>
> Hmm, I got as far as.......
>
> <choice>
> <element name="question" type="this:noAttributeType" />
> <element name="question"
> type="this:yesAttributeWithDescriptionType" />
> </choice>
>...


I think what you're trying to do requires a co-constraint, and is not
currently possible with XML schema. I believe Relax-NG can do this.

You could aim for something like:

<question number="2"><yes answer="This is the answer"></...

or some variation on that theme.

Pete.
--
=============================================
Pete Cordell
Tech-Know-Ware Ltd
for XML to C++ data binding visit
http://www.tech-know-ware.com/lmx
(or http://www.xml2cpp.com)
=============================================

 
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
efficient data loading with Python, is that possible possible? igor.tatarinov@gmail.com Python 10 12-14-2007 04:44 PM
is it possible to possible to create an iterator from a callback interace? aninnymouse@gmail.com C Programming 4 02-21-2006 02:10 PM
XML + XSD: Is it possible to get all possible Values for an Element? Markus Java 1 11-22-2005 02:51 PM
Possible to connect 2 computers via USB? Michael Giroux Wireless Networking 2 09-02-2004 03:27 AM
Possible domain related wireless problem =?Utf-8?B?QWxpIEQ=?= Wireless Networking 0 08-10-2004 01:59 AM



Advertisments