Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > some elements with same name but different attributtes

Reply
Thread Tools

some elements with same name but different attributtes

 
 
Freeter
Guest
Posts: n/a
 
      12-29-2006
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!

 
Reply With Quote
 
 
 
 
=?ISO-8859-1?Q?P=E8re_No=EBl?=
Guest
Posts: n/a
 
      12-29-2006
Freeter <(E-Mail Removed)> 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
--
Pre Nol
 
Reply With Quote
 
 
 
 
Peter Flynn
Guest
Posts: n/a
 
      12-29-2006
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/
 
Reply With Quote
 
Freeter
Guest
Posts: n/a
 
      01-03-2007
Thanks, Pre, 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/


 
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
Weird issue, same code, same browser, two different apache servers,very different css bluebaron HTML 3 11-04-2009 07:13 PM
running same script on same data on two different machines -->different result Christopher Brewster Python 5 11-14-2008 08:19 PM
list of html code same but output is different on different browsers pradeep HTML 3 06-07-2007 05:54 PM
RMI binding to SAME port but DIFFERENT IP address on SAME host Alexander N. Spitzer Java 21 08-16-2004 12:41 AM
same code produces different decimal symbol on different computers with same settings ASP General 2 12-29-2003 02:29 PM



Advertisments