473,795 Members | 3,441 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Xerces and .NET System.Xml

Hi everybody:

I do not know if this is the correct list to a very specific
implementation problem, but if you can help me, it would be great! :)

I have one application that builds a Xml that contains some strange
characters:

std::string str = "Code = ";
str += '♦'; //strange character ASCII 4

and I serialize the Xml using Xerces and Xerces writes something like
(no matter the encoding I am using; I tried iso-8859-1; utf-8; utf-16,
etc.)

<XmlTest>
Code = ♦
</XmlTest>
But when I want to load this Xml using the Microsoft .NET
System.Xml.XmlD ocument, I get an:

"Invalid character found" exception and the XML cannot be loaded.

What is wrong here? If I try to serialize the same String using the MS
implementation, I get a:

<XmlTest>
Code = &x4;
</XmlTest>

Jun 27 '08 #1
5 3059
Ernesto Bascón Pantoja wrote:
I have one application that builds a Xml that contains some strange
characters:

std::string str = "Code = ";
str += '♦'; //strange character ASCII 4
ASCII 4 is not allowed in XML 1.0 and only allowed as numeric character
reference in XML 1.1 I think.
Why do you want to put such characters into your XML documents?

What is wrong here? If I try to serialize the same String using the MS
implementation, I get a:

<XmlTest>
Code = &x4;
</XmlTest>
..NET is not necessarily complying with the XML 1.0 specification, it
allows you to serialize such characters as numeric character references.
You can turn that off by using an XmlWriter with XmlWriterSettin gs where
CheckCharacters is set to true.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jun 27 '08 #2
On Apr 22, 1:29 pm, Martin Honnen <mahotr...@yaho o.dewrote:
Ernesto Bascón Pantoja wrote:
I have one application that builds a Xml that contains some strange
characters:
std::string str = "Code = ";
str += '♦'; //strange character ASCII 4

ASCII 4 is not allowed in XML 1.0 and only allowed as numeric character
reference in XML 1.1 I think.
Why do you want to put such characters into your XML documents?
I am getting clear text from a database and I serialize it into a XML
to allow a .NET client to receive such information;
the problem occurs when the "clear text" comes with those characters
or with international characters. Xerces performs the serialization
but does not transform the '♦' or the 'ß' in 'Straße' and serializes
them as they come.

I do not know if written directy those characters with utf-8 encoding
is valid.
Jun 27 '08 #3
ASCII 4 is not a legal XML 1.0 character, no matter what your encoding
is or how you try to escape it. I'd suggest introducing something like
<mychar codepoint="4"/and having your application code convert this
appropriately. Or do a base-64 encoding on your block of binary code and
have the application convert that appropriately.

XML 1.1 relaxes restrictions on characters somewhat. I'm not sure
offhand whether it would let you get away with this one or not. But
support for 1.1 is, alas, still extremely rare; you may have to beat up
your XML library suppliers to get it, and having gotten it you may have
trouble interchanging those files with other applications or users that
haven't yet upgraded.
Jun 27 '08 #4
On Apr 22, 1:54 pm, "Joseph J. Kesselman" <keshlam-nos...@comcast. net>
wrote:
ASCII 4 is not a legal XML 1.0 character, no matter what your encoding
is or how you try to escape it. I'd suggest introducing something like
<mychar codepoint="4"/and having your application code convert this
appropriately. Or do a base-64 encoding on your block of binary code and
have the application convert that appropriately.
So, how can I say to Xerces: "given this string, transcode the special
characters to their Unicode escape sequence (i.e. &4;)

XML 1.1 relaxes restrictions on characters somewhat. I'm not sure
offhand whether it would let you get away with this one or not. But
support for 1.1 is, alas, still extremely rare; you may have to beat up
your XML library suppliers to get it, and having gotten it you may have
trouble interchanging those files with other applications or users that
haven't yet upgraded.
Jun 27 '08 #5
Ernesto Bascón Pantoja wrote:
So, how can I say to Xerces: "given this string, transcode the special
characters to their Unicode escape sequence (i.e. &4;)
Xerces deals with XML. The 0x04 character is not XML. (Or at least not
XML 1.0), so it isn't Xerces' responsibility to deal with it.

If you must represent this character in data that's expressed as XML,
it's your application's responsibility to use some alternate escaping
solution (such as the element I suggested, or base-64 encoding, or
whatever).

If you really want this character to appear as itself in the file...
that isn't an XML file and you can't expect XML tools to either accept
it or generate it.

Take a long step back from this detail and look at the the actual
problem you're trying to solve. You haven't told us that, so we can't
say more than that the specific solution you've proposed here doesn't work.
Jun 27 '08 #6

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

Similar topics

0
1776
by: BODIN | last post by:
I have an XML document, which is actually physically stored in 2 separated files. doc1.xml and doc2.xml I NEED a WAY FOR THIS SIMPLE NEED : XML file splitted into two physical files, and use of XML Schema.
2
4661
by: Olaf Meyer | last post by:
Apprentently xerces 2.6.0 (Java) does not validate against contraints specified in the schema (e.g. constraints specified via unique element). The validation works with the XML editor I'm using (XMLSpy4) but not with Xerces 2.6.0. I've included a really short and simple example to illustrate it. I would like to get some comments on the validation capabilities of Xerces 2.6.0. I though it *fully* supported W3C Schema!
4
5611
by: joes | last post by:
Hello there I tried for several days to get a simple validation with xml schema & xerces working. Goal for me is tuse JAXP and not specific Xerces classes. I don't get the point what I am doing wrong. Could somebody help me? I didn't find any full example working on the net. Thank you for any hints! If I run the examples below, the parsers parses the file well, no vlaidation is occuring although the schema and xml file does not
0
1854
by: Jim Phelps | last post by:
After having memory leak issues with Xerces-c 2.3.0 for Solaris 2.7 for CC 6.2 I have decided to update to at least 2.4. I have downloaded the binary tarball and have installed it on my development server, which runs Solaris 2.8. I do use CC 6.2 for my compiler. I have reset all the environment variables in Korn shell that point to the Xerces distribution. When I try to compile the same piece of code that compiles fine under Xerces...
4
1757
by: SL | last post by:
Hi, Im' using Xerces-j (version 2.0.1 and 2.6.2). When parsing this prolog : <!DOCTYPE teiCorpus PUBLIC "-//TEI Consortium//DTD TEI P4//EN" "d:/Program Files/tei-emacs/sgml/dtds/tei/tei2.dtd" The same thing appens with external entity uri declaration :
2
3959
by: Cigdem | last post by:
Hello, I am trying to parse the XML files that the user selects(XML files are on anoher OS400 system called "wkdis3"). But i am permenantly getting that error: Directory0: \\wkdis3\ROOT\home Canonicalpath-Directory4: \\wkdis3\ROOT\home\bwe\ You selected the file named AAA.XML getXmlAlgorithmDocument(): IOException Not logged in
7
13350
by: Georg J. Stach | last post by:
Hi, as mentioned above I'd like to validate a simple XML-document with a simple DTD. For this, I use Java and Xerces. But, when I have tags of this form: <tag>some characters in here</tag> Xerces always complains with:
4
3059
by: cgparis | last post by:
Dear forum members, I am trying to compile C++ code under MS Visual Studio .NET 2003, which references the latest Xerces C++ release library (2.6.0). This Xerces release was made available recently by the Apache organization. I've defined a system variable on windows as follows: XERCESCROOT: <...>\xerces-c_2_6_0-windows_nt-msvc_60
3
5939
by: Dhirendra Singh | last post by:
I am new to xml parsing concept. can anyone suggest good books on Xerces C++ parsers. API documentation provided by apache is very raw and i do not find it very useful.
2
2362
by: Boris Kolpackov | last post by:
Hi, I am pleased to announce the availability of Apache Xerces-C++ 3.0.0. Xerces-C++ is an open-source validating XML parser written in a portable subset of C++. It provides DOM (level 1, 2, and 3), SAX, and SAX2 APIs and supports validation of XML documents against DTD and XML Schema. This release includes a large number of new features, bug fixes, and clean-ups, including:
0
10214
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10164
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
10001
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9042
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6780
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5437
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2920
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.