Defining different elements in XML Schema

Discussion in 'XML' started by fulvio.risso@gmail.com, Oct 6, 2005.

  1. Guest

    Hello guys.

    I would like to use the following two types of elements in my XML file:

    <field type="fixed" size="10"/>
    <field type="variable" expr="a+b"/>

    The problem is that I cannot find a way to define the proper XML
    schema. The problem is that I would like to define an element
    ("<field>") which may have different syntax according to the value of
    one of its attribute. It seems to me that a solution is to use
    "xsi:type=..." in the XML file, but I don't want to do that.

    Does anybody have a solution for this (maybe stupid) problem?

    Cheers,

    fulvio
    , Oct 6, 2005
    #1
    1. Advertising

  2. Soren Kuula Guest

    wrote:

    > Does anybody have a solution for this (maybe stupid) problem?


    Hi,

    The stupid one is not you..

    You can't specify the dependence of anything on attribute values in XML
    Schema.

    Relax NG can do it, and it's a much nicer language to work with (my
    opinion anyway).

    Soren
    Soren Kuula, Oct 6, 2005
    #2
    1. Advertising

  3. Can you use this instead?

    <fields>
    <fixed size="10"/>
    <variable expr="a+b"/>
    </fields>

    --
    Stan Kitsis
    Program Manager, XML Technologies
    Microsoft Corporation

    This posting is provided "AS IS" with no warranties, and confers no rights.

    <> wrote in message
    news:...
    > Hello guys.
    >
    > I would like to use the following two types of elements in my XML file:
    >
    > <field type="fixed" size="10"/>
    > <field type="variable" expr="a+b"/>
    >
    > The problem is that I cannot find a way to define the proper XML
    > schema. The problem is that I would like to define an element
    > ("<field>") which may have different syntax according to the value of
    > one of its attribute. It seems to me that a solution is to use
    > "xsi:type=..." in the XML file, but I don't want to do that.
    >
    > Does anybody have a solution for this (maybe stupid) problem?
    >
    > Cheers,
    >
    > fulvio
    >
    Stan Kitsis [MSFT], Oct 7, 2005
    #3
  4. Hi,

    Just out of curiosity, why don't you want to use xsi:type? It's a
    simple matter of adding a namespace declaration in your document, and
    prefix to your type attributes:

    <field xsi:type="fixed" size="10"/>
    <field xsi:type="variable" expr="a+b"/>

    Priscilla

    ----------------------------------
    Priscilla Walmsley
    Author, Definitive XML Schema
    http://www.datypic.com
    ----------------------------------

    *** Sent via Developersdex http://www.developersdex.com ***
    Priscilla Walmsley, Oct 7, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Markus
    Replies:
    1
    Views:
    1,530
    Markus
    Nov 23, 2005
  2. Stanimir Stamenkov
    Replies:
    9
    Views:
    1,026
    David Carlisle
    Jan 26, 2005
  3. Stanimir Stamenkov
    Replies:
    3
    Views:
    1,251
    Stanimir Stamenkov
    Apr 25, 2005
  4. Replies:
    5
    Views:
    760
    Priscilla Walmsley
    Jan 16, 2006
  5. Replies:
    3
    Views:
    2,835
Loading...

Share This Page