473,390 Members | 942 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,390 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 4112
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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
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...

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.