473,562 Members | 2,931 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

invalid XML character

I have two applications that should comunicate through an xml file. This
xml will contain a CDATA section with a digital signature.

The problem is that the digital signature is composed of special
character that are nor correctly recognized by the xml parser.

When you try to open the follow file with an xml editor, like jedit, you
will see that the CDATA block is marked with follow error:
"An invalid XML character (Unicode: 0x6) was found in the CDATA section."

This is the xml file:

<?xml version="1.0" encoding="utf-8"?>
<Document>
<DataBlock>
<![CDATA[0‚V_ *†H†÷
 ‚VP0‚VL1 0+0‚FO *†H†÷
 ‚F@‚F<Content-Type: multipart/mixed;
boundary="----=_NextPart_717_ 3066_3832508151 693287"
MIME-Version: 1.0
X-Mailer: EldoS MIMEBlackbox Library, version: 2004.04.16
Date: Sat, 4 Dec 2004 19:33:50 +0100
Message-ID: <20041204193350 0630@69768441>

This is a multi-part message in MIME format.

------=_NextPart_717_ 3066_3832508151 693287
Content-Type: text/html;
charset="utf-8"
Content-Transfer-Encoding: base64
]]>
</DataBlock>
</Document>
How can I handle this special content in an xml file ? Should I use an
other encoding ?
bye marco
Jul 20 '05 #1
6 8810


Marco Montel wrote:

The problem is that the digital signature is composed of special
character that are nor correctly recognized by the xml parser.

When you try to open the follow file with an xml editor, like jedit, you
will see that the CDATA block is marked with follow error:
"An invalid XML character (Unicode: 0x6) was found in the CDATA section."


In XML 1.0 0x6 is indeed not an allowed character so you need to encode
it, using Base64 encoding for instance.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 20 '05 #2
Martin Honnen wrote:


Marco Montel wrote:

The problem is that the digital signature is composed of special
character that are nor correctly recognized by the xml parser.

When you try to open the follow file with an xml editor, like jedit,
you will see that the CDATA block is marked with follow error:
"An invalid XML character (Unicode: 0x6) was found in the CDATA section."

In XML 1.0 0x6 is indeed not an allowed character so you need to encode
it, using Base64 encoding for instance.


This is a great idea ! I didn't know that the xml 1.0 specification does
not allow some control caracter. I see that xml 1.1 allow that, but my
parser support only the XML 1.0 specification.

thanks a lot

bye marco
Jul 20 '05 #3
Marco Montel <ma**********@s yncromed.it> writes:
Martin Honnen wrote:


Marco Montel wrote:

The problem is that the digital signature is composed of special
character that are nor correctly recognized by the xml parser.

When you try to open the follow file with an xml editor, like jedit,
you will see that the CDATA block is marked with follow error:
"An invalid XML character (Unicode: 0x6) was found in the CDATA section."

In XML 1.0 0x6 is indeed not an allowed character so you need to encode
it, using Base64 encoding for instance.


This is a great idea ! I didn't know that the xml 1.0 specification does
not allow some control caracter. I see that xml 1.1 allow that, but my
parser support only the XML 1.0 specification.

thanks a lot

bye marco


Even XML 1.1 wouldn't allow the character in a CDATA section.

in XML 1.1 you can encode the character as a character reference, but
you can't have character references in a CDATA section (as & has no
special meaning in a CDATA section)

David
Jul 20 '05 #4
I'm a total beginner, and I hope you won't mind a stupid question. I
don't understand your point about the ampersand not having a special
meaning in the CDATA section. Can you elaborate on that? Would it have
a special meaning elsewhere? Why would it need a special meaning in the
CDATA section? I thought CDATA sections were there when you wanted the
parser to ignore everything in the secton and just pass the text
through.

Jul 20 '05 #5
On 7 Dec 2004 20:59:14 -0800, lk******@geocit ies.com wrote:
...I don't understand your point about the ampersand not
having a special meaning in the CDATA section ... Would it have
a special meaning elsewhere?
Yes; in a PCDATA section (e.g. inside "normal" marked up content) the
ampersand does have a special meaning, it signals to the parser that
"here is a possible start of an entity, or a numeric character,
reference".
Why would it need a special meaning in the CDATA section?
It does not "need" to have a special meaning and, per definition of
CDATA, it _can_not_ have a special meaning in CDATA.
I thought CDATA sections were there when you wanted the parser to
ignore everything in the section and just pass the text through.


Yep, that's about it.

--
Rex
Jul 20 '05 #6

Roland's pretty much answered this already but just to be explict.

the point I was making was that you can't have character 1 in XML 1 as
it's a banned control character, but in XML 1.1 (if your application
supports it, which most don't yet) you can not have the literal control
character but you can have " & # 1 ; " (without the spaces) to refer to
that character which will then appear as the character with unicode
number 1 if you look at the document using and API. DOM, SAX, XPath etc.

However the error message in the original posting refered to a CDATA
section but you can not refer to character 1 in a CDATA section even in
XML 1.1 as in:

"< [ C D A T A & # 1 ; ] ] > "

The & does not start a character reference as it is no longer special,
it just starts itself so the above (again without the spaces) is the
equvalent to

"& a m p ; # 1 ; "
David
(Spaces added as some (bad) newsreaders/mailreaders are confused by
character references and try to interpret them even in a plain text
message)

Jul 20 '05 #7

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

Similar topics

6
11835
by: cgbusch | last post by:
"Character reference "&#c" is an invalid XML character" With JDOM and Xerces in Java, I get the above error with sequences. I need to be able to encode arbitrary char sequences in xml. any suggestions? -- CB
3
19735
by: Kaidi | last post by:
Hello guys, I get the "an invalid XML character" error when using xerces to parse a XML file. I know that XML will correspond the &, <, >, " to special strings like "&gt;&lt;". However, how about if the XML file really needs to contain some text like: "&#x3;&#x4;&#x14;&#x8;&#x8;"? (as content of a tag) The story is: I am writing a program to...
9
8138
by: Safalra | last post by:
The idea here is relatively simple: a java program (I'm using JDK1.4 if that makes a difference) that loads an HTML file, removes invalid characters (or replaces them in the case of common ones like Microsoft's 'smartquotes'), and outputs the file. The problem is these files will be on disk, so the program won't have the character encoding...
3
3728
by: Gabriele Poggi | last post by:
How can I load an xml document, with some invalid character, with the method doc.load(), without exceptions? I have already tried to insert a CDATA Sections in the xml file source, but the result is the same. Thanks.. Gabriele
1
10147
by: King Kong | last post by:
we are facing this kind of error when we double click the infragistic web grid please help me on this Regards Moid Iqbal Server Error in '/NetworkAccess' Application. ---------------------------------------------------------------------------- ----
2
2014
by: none | last post by:
Hi, I'm opening a popup window with JavaScript. It has a command button. This is from the primary source (opener) window: ################################################################### // ======================================================= function popup01 () { var win_url
2
3500
by: sachinik19 | last post by:
Hi, We are using SAXParser (xerces) for parsing an xml with utf-8 encoding. For some special character it gives SAXException with error message - "The invalid character is found in the document ". But for other errors also it gives the same Exception only with different message. Is there any way to detect that the error is because of the...
1
2357
by: =?Utf-8?B?UGF1bCBQaGlsbGlwcw==?= | last post by:
I have read many things about this but I haven't got a clear vision on what to do if anything about this. I have a system that tries to find holes in my web site. One of the things it has found and has been sent to me is an Invalid_Viewstate exception. I will provide the stack trace below. If you read down the stack trace it talks...
1
2794
by: eBob.com | last post by:
I have some code which is trying to determine where text will wrap in a custom text box (which Inherits from Control). It determines the number of characters which will fit in the first line, but then encounters an exception when it calls MeasureCharacterRanges to see if the next character, i.e. the one destined to become the first character...
0
7655
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7577
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7869
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8101
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7627
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7935
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6221
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5477
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
903
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.