Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old December 29th, 2006, 02:55 AM
Freeter
Guest
 
Posts: n/a
Default some elements with same name but different attributtes

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!

  #2  
Old December 29th, 2006, 08:45 AM
=?ISO-8859-1?Q?P=E8re_No=EBl?=
Guest
 
Posts: n/a
Default Re: some elements with same name but different attributtes

Freeter <Freeterx@gmail.comwrote:
Quote:
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
  #3  
Old December 29th, 2006, 01:45 PM
Peter Flynn
Guest
 
Posts: n/a
Default Re: some elements with same name but different attributtes

Freeter wrote:
Quote:
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/
  #4  
Old January 3rd, 2007, 07:45 AM
Freeter
Guest
 
Posts: n/a
Default Re: some elements with same name but different attributtes

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 дµÀ£º
"
Quote:
Freeter wrote:
Quote:
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/
 

Bookmarks

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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles