PC Review


Reply
Thread Tools Rate Thread

Can't duplicate any field names in XML?

 
 
Guest
Posts: n/a
 
      26th May 2007
Given an XML file (dataset.writexml), here is my output (simplified for this
posting):

<?xml version="1.0" standalone="yes"?>
<NewDataSet>
<Category>
<CategoryId>80</CategoryId>
<Category>MyCat</Category>
</Category>
</NewDataSet>

But when I debug the field names, I see that my app is tweaking the field
names, apparently because they are dupes (?).

?ds.Tables(0).TableName
"Category"
?ds.Tables(0).Columns(0).ColumnName
"CategoryId"
?ds.Tables(0).Columns(1).ColumnName
"Category_Id"

Am I not allowed to duplicate field and/or table names?

Looks like because my table is named "Category", that I can't also have
field named "Category".

If so, then I can't have an easy translation from SQL Server (PK/FK similar
field names) to XML. I guess I have to tweak my field names before writing
to XML? How should I go about doing this, or am I getting something wrong.

Thx.


 
Reply With Quote
 
 
 
 
John Saunders [MVP]
Guest
Posts: n/a
 
      27th May 2007
<-> wrote in message news:eYTBvP%(E-Mail Removed)...
> Given an XML file (dataset.writexml), here is my output (simplified for
> this posting):
>
> <?xml version="1.0" standalone="yes"?>
> <NewDataSet>
> <Category>
> <CategoryId>80</CategoryId>
> <Category>MyCat</Category>
> </Category>
> </NewDataSet>
>
> But when I debug the field names, I see that my app is tweaking the field
> names, apparently because they are dupes (?).
>
> ?ds.Tables(0).TableName
> "Category"
> ?ds.Tables(0).Columns(0).ColumnName
> "CategoryId"
> ?ds.Tables(0).Columns(1).ColumnName
> "Category_Id"
>
> Am I not allowed to duplicate field and/or table names?
>
> Looks like because my table is named "Category", that I can't also have
> field named "Category".
>
> If so, then I can't have an easy translation from SQL Server (PK/FK
> similar field names) to XML. I guess I have to tweak my field names before
> writing to XML? How should I go about doing this, or am I getting
> something wrong.


I'd say that what you got "wrong" is that you misuse the concept of a name.
I always say to name a thing for what it is, which implies that things with
the same name should be the same thing. Clearly, your "Category" field is
not the same as your "Category" table. Perhaps your "Category" field would
better be named "CategoryName". It will presumably be a unique field.
--
John Saunders [MVP]


 
Reply With Quote
 
Guest
Posts: n/a
 
      27th May 2007
In a relational database, it's not uncommon to name an attribute the same as
the entity when applied to the physical world.

Category, which is an entity, has a similarly-named attrbute.

CATEGORY
CategoryID
Category

This concept, in the XML world, fails, right?

I'm asking for supporting evidence from people who know better than my
cursory experience, which seems to suggest that.

That you attacked my physical implementation doesn't address my question,
nor does it seem to get around the fact that this appears to be a strong
limitation to XML. Unless there's a way around that. If so, I'd like to know
how.

Also, you don't know that I'm responsible to create the database. For all
you know, someone else may have implemented this, and I'm just working
around that. Either way, you have decided to attack me.

MVP? What does that stand for? Most Vile Pinhead?

(No offense intended to other MVPs who go out of their way to help people.
Guess you're just having a bad day).


"John Saunders [MVP]" <john.saunders at trizetto.com> wrote in message
news:eXqVF1$(E-Mail Removed)...
> <-> wrote in message news:eYTBvP%(E-Mail Removed)...
>> Given an XML file (dataset.writexml), here is my output (simplified for
>> this posting):
>>
>> <?xml version="1.0" standalone="yes"?>
>> <NewDataSet>
>> <Category>
>> <CategoryId>80</CategoryId>
>> <Category>MyCat</Category>
>> </Category>
>> </NewDataSet>
>>
>> But when I debug the field names, I see that my app is tweaking the field
>> names, apparently because they are dupes (?).
>>
>> ?ds.Tables(0).TableName
>> "Category"
>> ?ds.Tables(0).Columns(0).ColumnName
>> "CategoryId"
>> ?ds.Tables(0).Columns(1).ColumnName
>> "Category_Id"
>>
>> Am I not allowed to duplicate field and/or table names?
>>
>> Looks like because my table is named "Category", that I can't also have
>> field named "Category".
>>
>> If so, then I can't have an easy translation from SQL Server (PK/FK
>> similar field names) to XML. I guess I have to tweak my field names
>> before writing to XML? How should I go about doing this, or am I getting
>> something wrong.

>
> I'd say that what you got "wrong" is that you misuse the concept of a
> name. I always say to name a thing for what it is, which implies that
> things with the same name should be the same thing. Clearly, your
> "Category" field is not the same as your "Category" table. Perhaps your
> "Category" field would better be named "CategoryName". It will presumably
> be a unique field.
> --
> John Saunders [MVP]
>
>



 
Reply With Quote
 
John Saunders [MVP]
Guest
Posts: n/a
 
      27th May 2007
<-> wrote in message news:(E-Mail Removed)...
> In a relational database, it's not uncommon to name an attribute the same
> as the entity when applied to the physical world.
>
> Category, which is an entity, has a similarly-named attrbute.
>
> CATEGORY
> CategoryID
> Category
>
> This concept, in the XML world, fails, right?
>
> I'm asking for supporting evidence from people who know better than my
> cursory experience, which seems to suggest that.
>
> That you attacked my physical implementation doesn't address my question,
> nor does it seem to get around the fact that this appears to be a strong
> limitation to XML. Unless there's a way around that. If so, I'd like to
> know how.
>
> Also, you don't know that I'm responsible to create the database. For all
> you know, someone else may have implemented this, and I'm just working
> around that. Either way, you have decided to attack me.
>
> MVP? What does that stand for? Most Vile Pinhead?
>
> (No offense intended to other MVPs who go out of their way to help people.
> Guess you're just having a bad day).


You asked me what you had gotten "wrong", so I put my reply in those terms.
I'm aware that occasionally the entity is named the same as a piece of it -
I've done database work since before relational databases - and I stick to
my contention that two things should have the same name only if they are the
same thing. And the attribute isn't "similarly-named", it is identically
named, suggesting that it is (impossibly) the identical thing.

I _do_ prefer to distinguish between the entity, it's primary key (ID), a
textual equivalent to the primary key (Name) and a textual description. If
the naming were left to me, there would be a Category table, with CategoryID
as its primary key, with CategoryName as a unique field, and with
CategoryDescription as a non-unique, longer text description. This would
make all of the relationships clear, instead of saving four characters in a
column name by omitting "Name".

I responded with such a "philosophical" or "stylistic" response because I
believe that your practical problem is related to the stylistic one - in the
same way as the naming of this database would confuse human readers, I
believe that you have confused the software! Both problems would be
alleviated by giving a distinct name to the entity and to each of its
fields.

Now, you've got a very similar problem in your XML. It seems that you want
to have one element named "Category" which is of a complex type containing a
CategoryID and a Category, yet that second Category is meant to be of a
different type that the root "Category". Again, this is the result of giving
the same name to different things, and will only cause trouble. In this
case, you would need to convince software that, although these two elements
have the same name, they are actually unrelated (except for the name). Why,
for instance, should software not expect the following XML:

<Category>
<CategoryID>1</CategoryID>
<Category>
<CategoryID>2</Category>
<Category>....

So, frankly, it's not a problem with the XML world, nor a benefit that the
relational world has - it's just a matter of the fact that the naming
convention you were using (whether or not you are responsible for creating
it) is confusing to both humans and to software. Correcting the naming issue
would solve the problem both for humans and for XML, and would prevent this
from becoming a problem with the next piece of software which assumes that
names mean something.
--
John Saunders [MVP]

P.S. Personally, I would have saved the word "vile" for something a lot
worse than my answer to you, but I suppose that's a matter of taste.


 
Reply With Quote
 
KJ
Guest
Posts: n/a
 
      28th May 2007
XML names are case-sensitive, so CATEGORY is not the same as Category.
Simply change the column aliases in your SELECT statements to something
unique -- the aliases will become the XML names and your collisions will be
resolved.

<-> wrote in message news:(E-Mail Removed)...
> In a relational database, it's not uncommon to name an attribute the same
> as the entity when applied to the physical world.
>
> Category, which is an entity, has a similarly-named attrbute.
>
> CATEGORY
> CategoryID
> Category
>
> This concept, in the XML world, fails, right?
>
> I'm asking for supporting evidence from people who know better than my
> cursory experience, which seems to suggest that.
>
> That you attacked my physical implementation doesn't address my question,
> nor does it seem to get around the fact that this appears to be a strong
> limitation to XML. Unless there's a way around that. If so, I'd like to
> know how.
>
> Also, you don't know that I'm responsible to create the database. For all
> you know, someone else may have implemented this, and I'm just working
> around that. Either way, you have decided to attack me.
>
> MVP? What does that stand for? Most Vile Pinhead?
>
> (No offense intended to other MVPs who go out of their way to help people.
> Guess you're just having a bad day).
>
>
> "John Saunders [MVP]" <john.saunders at trizetto.com> wrote in message
> news:eXqVF1$(E-Mail Removed)...
>> <-> wrote in message news:eYTBvP%(E-Mail Removed)...
>>> Given an XML file (dataset.writexml), here is my output (simplified for
>>> this posting):
>>>
>>> <?xml version="1.0" standalone="yes"?>
>>> <NewDataSet>
>>> <Category>
>>> <CategoryId>80</CategoryId>
>>> <Category>MyCat</Category>
>>> </Category>
>>> </NewDataSet>
>>>
>>> But when I debug the field names, I see that my app is tweaking the
>>> field names, apparently because they are dupes (?).
>>>
>>> ?ds.Tables(0).TableName
>>> "Category"
>>> ?ds.Tables(0).Columns(0).ColumnName
>>> "CategoryId"
>>> ?ds.Tables(0).Columns(1).ColumnName
>>> "Category_Id"
>>>
>>> Am I not allowed to duplicate field and/or table names?
>>>
>>> Looks like because my table is named "Category", that I can't also have
>>> field named "Category".
>>>
>>> If so, then I can't have an easy translation from SQL Server (PK/FK
>>> similar field names) to XML. I guess I have to tweak my field names
>>> before writing to XML? How should I go about doing this, or am I getting
>>> something wrong.

>>
>> I'd say that what you got "wrong" is that you misuse the concept of a
>> name. I always say to name a thing for what it is, which implies that
>> things with the same name should be the same thing. Clearly, your
>> "Category" field is not the same as your "Category" table. Perhaps your
>> "Category" field would better be named "CategoryName". It will presumably
>> be a unique field.
>> --
>> John Saunders [MVP]
>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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
Duplicate Field Names .:RoKsTaR:. Microsoft Access 10 25th May 2010 01:16 PM
CSV Import with duplicate field names Mike Microsoft Access External Data 3 15th Sep 2008 09:16 AM
duplicate names in field =?Utf-8?B?bGlzYSBtaWxidXJu?= Microsoft Access Queries 4 4th Sep 2007 01:37 AM
Duplicate Field Names =?Utf-8?B?TWVsaW5kYQ==?= Microsoft Access Queries 6 30th Jan 2007 03:31 PM
TO: Field shows duplicate names Brian Microsoft Outlook 1 20th Feb 2004 11:16 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:19 AM.