some elements with same name but different attributtes

Discussion in 'XML' started by Freeter, Dec 29, 2006.

  1. Freeter

    Freeter Guest

    Hi,
    I have an xml snippet like this:
    <ALabel name="ALabel1">
    <property vname="Location" x="388" y="384" z="223"/>
    <property vname="Label">
    <parameter vname="label">
    <String value="ALabel1"/>
    </parameter>
    </property>
    </ALabel>
    <APanel name="APanel1">
    <property height="440" vname="Size" width="456"/>
    <property vname="Location" x="712" y="220"/>
    <AImageSizedButton name="AImageSizedButton1">
    <property vname="Location" x="80" y="270"/>
    </AImageSizedButton>
    </APanel>
    If i define multi-property elements, the XMLSpy will give an error:
    "They must be defined with same name without dirivations!"
    How to define the schema for it? Thanks!
     
    Freeter, Dec 29, 2006
    #1
    1. Advertising

  2. Freeter <> wrote:

    > If i define multi-property elements, the XMLSpy will give an error:
    > "They must be defined with same name without dirivations!"
    > How to define the schema for it? Thanks!


    because i'm running over MacOS X i can't say about XMLSpy, but using the
    command line (dtdinst and trang) i get what u want here :

    <http://www.yvon-thoraval.com/Some/>

    hope this could help ;-)
    --
    Père Noël
     
    =?ISO-8859-1?Q?P=E8re_No=EBl?=, Dec 29, 2006
    #2
    1. Advertising

  3. Freeter

    Peter Flynn Guest

    Freeter wrote:
    > Hi,
    > I have an xml snippet like this:
    > <ALabel name="ALabel1">
    > <property vname="Location" x="388" y="384" z="223"/>
    > <property vname="Label">
    > <parameter vname="label">
    > <String value="ALabel1"/>
    > </parameter>
    > </property>
    > </ALabel>
    > <APanel name="APanel1">
    > <property height="440" vname="Size" width="456"/>
    > <property vname="Location" x="712" y="220"/>
    > <AImageSizedButton name="AImageSizedButton1">
    > <property vname="Location" x="80" y="270"/>
    > </AImageSizedButton>
    > </APanel>
    > If i define multi-property elements, the XMLSpy will give an error:
    > "They must be defined with same name without dirivations!"
    > How to define the schema for it? Thanks!


    Just make the relevant attributes optional.

    For example, all your property elements have a vname attribute, so I'm
    guessing that's probably compulsory. But x, y, and z don't always
    appear, so they must be optional; same for height and width.

    If specific combinations of attributes have to be compulsory, then they
    don't really describe the same thing (a "property") and should be
    encoded as a different element type, named separately with its own set
    of attributes. Get the data model right to start with, rather than
    trying to shoe-horn disparate objects into boxes made to fit something else.

    ///Peter
    --
    XML FAQ: http://xml.silmaril.ie/
     
    Peter Flynn, Dec 29, 2006
    #3
  4. Freeter

    Freeter Guest

    Thanks, P¨¨re, Peter!
    Yes, I think the best way now is to combine all the the attributes into
    Property and make them optional.
    Thanks again.

    "Peter Flynn дµÀ£º
    "
    > Freeter wrote:
    > > Hi,
    > > I have an xml snippet like this:
    > > <ALabel name="ALabel1">
    > > <property vname="Location" x="388" y="384" z="223"/>
    > > <property vname="Label">
    > > <parameter vname="label">
    > > <String value="ALabel1"/>
    > > </parameter>
    > > </property>
    > > </ALabel>
    > > <APanel name="APanel1">
    > > <property height="440" vname="Size" width="456"/>
    > > <property vname="Location" x="712" y="220"/>
    > > <AImageSizedButton name="AImageSizedButton1">
    > > <property vname="Location" x="80" y="270"/>
    > > </AImageSizedButton>
    > > </APanel>
    > > If i define multi-property elements, the XMLSpy will give an error:
    > > "They must be defined with same name without dirivations!"
    > > How to define the schema for it? Thanks!

    >
    > Just make the relevant attributes optional.
    >
    > For example, all your property elements have a vname attribute, so I'm
    > guessing that's probably compulsory. But x, y, and z don't always
    > appear, so they must be optional; same for height and width.
    >
    > If specific combinations of attributes have to be compulsory, then they
    > don't really describe the same thing (a "property") and should be
    > encoded as a different element type, named separately with its own set
    > of attributes. Get the data model right to start with, rather than
    > trying to shoe-horn disparate objects into boxes made to fit something else.
    >
    > ///Peter
    > --
    > XML FAQ: http://xml.silmaril.ie/
     
    Freeter, Jan 3, 2007
    #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. Alexander N. Spitzer
    Replies:
    21
    Views:
    1,783
    Randolf Richardson
    Aug 16, 2004
  2. pradeep
    Replies:
    3
    Views:
    808
    cwdjrxyz
    Jun 7, 2007
  3. Christopher Brewster
    Replies:
    5
    Views:
    345
    John Machin
    Nov 14, 2008
  4. bluebaron
    Replies:
    3
    Views:
    745
    Jonathan N. Little
    Nov 4, 2009
  5. Guest
    Replies:
    2
    Views:
    179
    Foo Man Chew
    Dec 29, 2003
Loading...

Share This Page