473,396 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Redundant xmlns attribute

If I have an XmlDocument with a deep hierarchy of nodes, with a
documentElement having an attribute xmlns="http://someurl.com" and all
children inheriting that namespace (but not having the xmlns attribute
explicitly declared), then why is it that when I perform
appendChild(someNode) on an existing node deep in the hierarchy, where
someNode has been created by an XmlSerializer with the namespace set to be
the aforementioned "http://someurl.com", the appended node has the xmlns
attribute explicitly declared in the output of saving the XmlDocument?

In other words, why doesn't AppendChild() remove redundant attributes that
are inherited from the parent, specifically xmlns?

Oh, it does? How do I instruct it to?

Greg
Mar 15 '07 #1
3 3882
"Greg" <Gr**@discussions.microsoft.comwrote in message
news:08**********************************@microsof t.com...
If I have an XmlDocument with a deep hierarchy of nodes, with a
documentElement having an attribute xmlns="http://someurl.com" and all
children inheriting that namespace (but not having the xmlns attribute
explicitly declared), then why is it that when I perform
appendChild(someNode) on an existing node deep in the hierarchy, where
someNode has been created by an XmlSerializer with the namespace set to be
the aforementioned "http://someurl.com", the appended node has the xmlns
attribute explicitly declared in the output of saving the XmlDocument?

In other words, why doesn't AppendChild() remove redundant attributes that
are inherited from the parent, specifically xmlns?
May I ask, why do you care? The "xmlns" aren't really attributes. They're
namespace declarations. What kind of problem is this causing you?

John
Mar 16 '07 #2
Having the redundant ns declarations bloats the file and slows parsing. I do
not know if it bloats/slows transmission of a similar hierarchy such as an
array of objects converted with XmlSerializer in the following web service:

[WebMethod]
MyStruct[] foo() {
MyStruct[] bar = new MyStruct[5];
for (int i = 0; i < 5 ++i) {
bar[i] = new MyStruct();
}
return bar;
}

Does each MyStruct in bar have its own namespace declaration in transit as
below, or does each MyStruct inherit the namespace declaration of
ArrayOfMyStruct?

<ArrayOfMyStruct xmlns="http://yadayada">
<MyStruct xmlns="http://yadayada">
...
</MyStruct>
<MyStruct xmlns="http://yadayada">
...
</MyStruct>
...
</ArrayOfMyStruct>

I am just trying to optimize my program for transmission/space/UI-latency
and XML handling is often a major offender. Having an Xml web-service that
transmits twice as much information as is necessary to yield the same effect
is silly, annoying, and detracts from a product that consumes it.

Greg
"John Saunders" wrote:
"Greg" <Gr**@discussions.microsoft.comwrote in message
news:08**********************************@microsof t.com...
If I have an XmlDocument with a deep hierarchy of nodes, with a
documentElement having an attribute xmlns="http://someurl.com" and all
children inheriting that namespace (but not having the xmlns attribute
explicitly declared), then why is it that when I perform
appendChild(someNode) on an existing node deep in the hierarchy, where
someNode has been created by an XmlSerializer with the namespace set to be
the aforementioned "http://someurl.com", the appended node has the xmlns
attribute explicitly declared in the output of saving the XmlDocument?

In other words, why doesn't AppendChild() remove redundant attributes that
are inherited from the parent, specifically xmlns?

May I ask, why do you care? The "xmlns" aren't really attributes. They're
namespace declarations. What kind of problem is this causing you?

John
Mar 19 '07 #3
"Greg" <Gr**@discussions.microsoft.comwrote in message
news:DF**********************************@microsof t.com...
Having the redundant ns declarations bloats the file and slows parsing. I
do
not know if it bloats/slows transmission of a similar hierarchy such as an
array of objects converted with XmlSerializer in the following web
service:

[WebMethod]
MyStruct[] foo() {
MyStruct[] bar = new MyStruct[5];
for (int i = 0; i < 5 ++i) {
bar[i] = new MyStruct();
}
return bar;
}

Does each MyStruct in bar have its own namespace declaration in transit as
below, or does each MyStruct inherit the namespace declaration of
ArrayOfMyStruct?

<ArrayOfMyStruct xmlns="http://yadayada">
<MyStruct xmlns="http://yadayada">
...
</MyStruct>
<MyStruct xmlns="http://yadayada">
...
</MyStruct>
...
</ArrayOfMyStruct>

I am just trying to optimize my program for transmission/space/UI-latency
and XML handling is often a major offender. Having an Xml web-service
that
transmits twice as much information as is necessary to yield the same
effect
is silly, annoying, and detracts from a product that consumes it.
Thanks for the reply, Greg.

My only addition is to ask by how much does it detract from the program that
consumes it? Have you measured the performance loss versus the cost of
fixing the problem?

Also, have you measured just how bad the problem is? Is the file really
twice as large?

Thanks,
John


Mar 19 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Saqib Ali | last post by:
Hello All, I am using Norman Walsh's XSLTs to transform some DocBook XML content to HTML. However I noticed that Norman Walsh's DocBook XSLT includes the following tag in the transformed...
3
by: Mike Dickens | last post by:
hi, i'm sure this has come up before but havn't managed to find an answer. if i have the following xslt <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet method="xml" version="1.0"...
0
by: chris.stromberger | last post by:
New to SOAP. I am working on something that uses the paypal web services. All the examples have this as the first portion of the soap doc <?xml version="1.0" encoding="UTF-8"?>...
0
by: Chuck Bowling | last post by:
Using this target schema: http://sourcepost.sytes.net/sourcepost/sourceview.aspx?source_id=24480 I generate this xml: http://sourcepost.sytes.net/sourcepost/sourceview.aspx?source_id=24481 using...
4
by: David S. Alexander | last post by:
I am trying to transform XML to XML using an XSLT in C#, but the root node of my XML is not being matched by the XSLT if it has an xmlns attribute. Am I handling my namespaces incorrectly? My C#...
3
by: dhurwitz | last post by:
I am trying to create an XML spreadsheet for use with Excel. I first saved a simple spreadsheet as an XML file, and now I am trying to recreate that file in code, using .NET 2.0. The beginning of...
0
by: jts2077 | last post by:
I am trying to create a large nested XML object using E4X methods. The problem is the, the XML I am trying to create can only have xmlns set at the top 2 element levels. Such as: <store ...
1
by: C.W.Holeman II | last post by:
I have an xmlns attribute that produces an XHTML validation error and I do not understand why it is considered an error.The file displays as expected on Firefox and IE7. ...
0
by: =?Utf-8?B?U2hhbm5vbiBCYXJiZXI=?= | last post by:
I have created a schema to write out some configuration data, and the OutPort element uses an abstract complex type (it can be a Message, Discrete, Continuous, Array, etc...). I use the provided...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.