Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   XML (http://www.velocityreviews.com/forums/f32-xml.html)
-   -   Schema question (http://www.velocityreviews.com/forums/t522375-schema-question.html)

Robert Dailey 07-16-2007 05:51 PM

Schema question
 
Take the following XML:


<Frame type="Image" id="frame1">
<Draw/>
</Frame>

<Frame type="Text" id="frame2">
<Print/>
</Frame>


Is there a way in Schema to specify that the "Frame" element is
different (and thus requires different child elements) depending on
the value of an attribute (specifically the "type" attribute)?


Joseph Kesselman 07-16-2007 06:05 PM

Re: Schema question
 
Robert Dailey wrote:
> Is there a way in Schema to specify that the "Frame" element is
> different (and thus requires different child elements) depending on
> the value of an attribute (specifically the "type" attribute)?


Presence or absence, maybe. Value, I don't think so. Some of the other
schema(-like) languages do support that, or you can enforce that
constrating in the application code...


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

Robert Dailey 07-16-2007 07:36 PM

Re: Schema question
 
On Jul 16, 1:05 pm, Joseph Kesselman <keshlam-nos...@comcast.net>
wrote:
> Robert Dailey wrote:
> > Is there a way in Schema to specify that the "Frame" element is
> > different (and thus requires different child elements) depending on
> > the value of an attribute (specifically the "type" attribute)?

>
> Presence or absence, maybe. Value, I don't think so. Some of the other
> schema(-like) languages do support that, or you can enforce that
> constrating in the application code...
>
> --
> Joe Kesselman / Beware the fury of a patient man. -- John Dryden


Thank you for your reply, it was the answer I was looking for.

I would also like to ask if it's possible to make a schema accept
either of the following attribute combinations for a single element:

<Offset x="0" y="0"/>
<Offset var="myvar"/>

Is this possible?


usenet@tech-know-ware.com 07-18-2007 08:55 AM

Re: Schema question
 
On 16 Jul, 20:36, Robert Dailey <rcdai...@gmail.com> wrote:
> On Jul 16, 1:05 pm, Joseph Kesselman <keshlam-nos...@comcast.net>
> wrote:
>
> > Robert Dailey wrote:
> > > Is there a way in Schema to specify that the "Frame" element is
> > > different (and thus requires different child elements) depending on
> > > the value of an attribute (specifically the "type" attribute)?

>
> > Presence or absence, maybe. Value, I don't think so. Some of the other
> > schema(-like) languages do support that, or you can enforce that
> > constrating in the application code...

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

>
> Thank you for your reply, it was the answer I was looking for.
>
> I would also like to ask if it's possible to make a schema accept
> either of the following attribute combinations for a single element:
>
> <Offset x="0" y="0"/>
> <Offset var="myvar"/>
>
> Is this possible?


In schema you can effectively only specify the union of the two
types. As a result things like <Offsett x="0" var="myvar"/> would
also validate. You could apply additional constraints at the
application level. XSD1.1 is due to improve onthis and Relax-NG
supports what you want.

HTH,

Pete.
--
=============================================
Pete Cordell
Codalogic Ltd
for XML Schema to C++ data binding visit
http://www.codalogic.com/lmx/
=============================================




All times are GMT. The time now is 04:09 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.