473,395 Members | 1,468 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,395 software developers and data experts.

problem with xml:lang

OJO
Hello microsoft.public.dotnet.xml!

I need to parse some 'jabber xml' (www.jabber.org). I opted for using
System.Xml.XmxDocument. The sample 'jabber xml' goes here:

<message xmlns='jabber:client' fr********@server.com/user1'
xml:lang='pl' type='groupchat' to*******@server.com/res'>
<body xmlns:xml='http://www.w3.org/XML/1998/namespace'>
MESSAGE TEXT
</body>
<x xmlns='jabber:x:delay' fr********@server.com' stamp='20040714T18:17:10'>
ch**@server.com
</x>
</message>

The problem is, that when I try:

doc.LoadXml(xml); // doc is a XmlDocument and xml is a string containing
above code

I get exception: "Namespace qualifiers beginning with 'xml' are reserved
and cannot be used in user-specified namespaces [line and column number
here]"

I also trid to add xml declaration:

doc.LoadXml("<?xml version='1.0' encoding='utf-8' ?>" + xml)

but with the same result.

I'm sure the xml is valid, because IE, VS, and Firefox
(http://www.mozilla.org/products/firefox/) find it valid.

I've been searching web (using google and msdn) for two days, but with
no results.

Mayby there is any way to overcome this problem? Or mayby there is some
other way to parser and validate xml i .net?

I'll be thankful for any information.

Sorry for my English - I'm still learning...

OJO
Nov 12 '05 #1
5 4113
OJO wrote:
I need to parse some 'jabber xml' (www.jabber.org). I opted for using
System.Xml.XmxDocument. The sample 'jabber xml' goes here:

<message xmlns='jabber:client' fr********@server.com/user1'
xml:lang='pl' type='groupchat' to*******@server.com/res'>
<body xmlns:xml='http://www.w3.org/XML/1998/namespace'>
xmlns:xml='http://www.w3.org/XML/1998/namespace' is the problem. This is
one piece of incompatibility brought to XML by XML namespaces. According
to original XML namespaces spec:

"The prefix xml is by definition bound to the namespace name
http://www.w3.org/XML/1998/namespace."
[http://www.w3.org/TR/REC-xml-names/#nsc-NSDeclared]

Apparently Microsoft's interpretation is "nobody can use xml as
namespace prefix, because it's bound by definition". We can see that
this interpretation is consistently implemented in all versions of MSXML
as well as in .NET.

Btw, recently XML Namespaces 1.1 clarified things a bit:
"The prefix xml is by definition bound to the namespace name
http://www.w3.org/XML/1998/namespace. It MAY, but need not, be declared,
and MUST NOT be undeclared or bound to any other namespace name."
[http://www.w3.org/TR/2004/REC-xml-na.../#xmlReserved]

But AFAIK Microsoft currently has no plans to support XML 1.1/ XML
Namespaces 1.1.
I'm sure the xml is valid, because IE, VS, and Firefox
(http://www.mozilla.org/products/firefox/) find it valid.

Are you sure about IE? My IE barfs at it:

The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error
and then click the Refresh button, or try again later.
--------------------------------------------------------------------------------

The namespace prefix is not allowed to start with the reserved string
"xml". Error processing resource 'file:///D:/projects...

<body xmlns:xml='http://www.w3.org/XML/1998/namespace'>
------^

So the only workareound is probably to remove
"xmlns:xml='http://www.w3.org/XML/1998/namespace'" substring from the
document before parsing.

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #2
OJO
Oleg Tkachenko [MVP] wrote:

xmlns:xml='http://www.w3.org/XML/1998/namespace' is the problem. This is
Thank, you. I though it was about xml:lang.

Are you sure about IE? My IE barfs at it:

You're right, i tested many lines of xml, and bogged down. Sorry.
So the only workareound is probably to remove
"xmlns:xml='http://www.w3.org/XML/1998/namespace'" substring from the
document before parsing.


Could you provide concrete example in c# or vb.net? I don't think it's
very smart to use string.Replace. Note that there might occur " instead
of ', and I'm not sure about URL (if it may be diffrent).

TIA

OJO
Nov 12 '05 #3
OJO wrote:
Could you provide concrete example in c# or vb.net? I don't think it's
very smart to use string.Replace. Note that there might occur " instead
of ', and I'm not sure about URL (if it may be diffrent).


The URL and th eprefix are always "http://www.w3.org/XML/1998/namespace"
and "xml". You may want to use regexp here. You need a pattern something
like

xmlns:xml\s*=\s*["']http://www.w3.org/XML/1998/namespace["']

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #4
OJO
Oleg Tkachenko [MVP] wrote:
The URL and th eprefix are always "http://www.w3.org/XML/1998/namespace"
and "xml". You may want to use regexp here. You need a pattern something
like

xmlns:xml\s*=\s*["']http://www.w3.org/XML/1998/namespace["']


Thank you, it helped me very much, but I'm afraid of it a little. What
about the situation when xmlns:xml... isn't param of tag, but simple
text? I know it isn't very likely, but not impossbie. I can't lose
valuable information it that way.

Thank you again.

OJO
Nov 12 '05 #5
OJO wrote:
Thank you, it helped me very much, but I'm afraid of it a little. What
about the situation when xmlns:xml... isn't param of tag, but simple
text? I know it isn't very likely, but not impossbie. I can't lose
valuable information it that way.


Yeah, I don't like it either. Should be a cleaner solution, but I fail
to see it right now.

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #6

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

Similar topics

5
by: Rafa³ | last post by:
How i use query in xml or xslt? Thanks
3
by: Alexander Gräf | last post by:
Hello, I'm stuck with a simple problem, for which I don't have a solution. I basically have an XML file containing fragments of plain text and html, in several languages: <?xml version="1.0"...
0
by: Martin Silar | last post by:
Hi, I canonicalize document subset and result is different from w3c.org examples. Do you know where is the problem? thanks Martin String xPath="(//. | //@* | //namespace::*)"; ...
8
by: Demon News | last post by:
I'm trying to do a transform (Using XmlTransform class in c#) and in the Transform I'm specifying the the output xsl below: <xsl:output method="xml" encoding="UTF-8" indent="no"/> the...
0
by: Martin | last post by:
Hi, I canonicalize document subset and result is different from w3c.org examples. Do you know where is the problem? thanks Martin String xPath="(//. | //@* | //namespace::*)"; ...
6
by: MONROUX philippe | last post by:
hi, In a file.xsl I have : ====================================================================== .... <xsl:variable name="LANGS" select="path"/> <xsl:template match="@*|node()">...
12
by: Andreas Prilop | last post by:
What was the reason to introduce a new attribute "xml:lang" instead of "lang"? This bothers both authors and browsers in different language versions: HTML 4, XHTML 1.0, XHTML 1.1. HTML has only...
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 ...
8
by: bitong | last post by:
*=A $=E output: Encrypted Message: M$$T M$ *T 1PM Decrypted Message: Meet me at 1PM Is this problem concerns with Arrays or strings?
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.