469,306 Members | 2,542 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,306 developers. It's quick & easy.

escape character in XML text string

Hi,

I am generating a XML based file for a system that will generate PCL code
from textual <text>..</text> tag items. The PCL string needs escape
characters. The string within this tag will be transparently forward to a
device that understands escape characters.

How can I include the character ' 27' into the data so that the XML is
properly formed and not rejected.

char c = '\u001b';
string = "ab" + c + "de" will not work.

Any ideas?

Gr. Ricardo

Jul 20 '05 #1
7 10103
* Te********@intervisit.com wrote in comp.text.xml:
I am generating a XML based file for a system that will generate PCL code
from textual <text>..</text> tag items. The PCL string needs escape
characters. The string within this tag will be transparently forward to a
device that understands escape characters.

How can I include the character ' 27' into the data so that the XML is
properly formed and not rejected.


You cannot include U+001B literally in XML documents, you need some
method to express U+001B in characters that are allowed in XML. In
common use are Base64 and Hex encoding.
Jul 20 '05 #2
On Wed, 21 Jan 2004 21:44:07 GMT, "Te********@intervisit.com"
<te********@intervisit.com> wrote:
How can I include the character ' 27' into the data so that the XML is
properly formed and not rejected.


Tried an entity ?


Jul 20 '05 #3
Andy Dingley wrote:
On Wed, 21 Jan 2004 21:44:07 GMT, "Te********@intervisit.com"
<te********@intervisit.com> wrote:

How can I include the character ' 27' into the data so that the XML is
properly formed and not rejected.

Tried an entity ?




Tried yourself?

Anyway: doesn't work. The character is illegal in XML, no matter whether
as entitiy or not.
Jul 20 '05 #4
On Thu, 22 Jan 2004 10:35:33 +0100, Julian Reschke
<ju************@gmx.de> wrote:
Anyway: doesn't work. The character is illegal in XML, no matter whether
as entitiy or not.


Sorry - gettiing late and I was tired. It's in the forbidden range
(I've never understood why - anyone care to explain the reasoning
behind them ?)

Jul 20 '05 #5
Andy Dingley wrote:
On Thu, 22 Jan 2004 10:35:33 +0100, Julian Reschke
<ju************@gmx.de> wrote:

Anyway: doesn't work. The character is illegal in XML, no matter whether
as entitiy or not.

Sorry - gettiing late and I was tired. It's in the forbidden range
(I've never understood why - anyone care to explain the reasoning
behind them ?)


Escape sequences are used to control output devices, eg to change fonts,
clear the screen, switch to block graphics mode, and goddess knows what
else.

You really, *really*, REALLY don't want ESC in your output stream, ever,
unless you are writing a device controller.

The OP wanted to use an XML stream for device control, which IMHO is
A Bad Idea. The simple solution is to insert a placeholder like <ESC/>
and pass the file through a transformation stage that *will* output
a \027 character.

///Peter

Jul 20 '05 #6
On Sat, 24 Jan 2004 02:21:44 +0000, Peter Flynn <pe***@silmaril.ie>
wrote:
You really, *really*, REALLY don't want ESC in your output stream, ever,
unless you are writing a device controller.


But what if I am ?

 is a good "XML-like" solution to handling these potentially
volatile characters. Represented as an entity, it ain't going nowhere
(equally for your <ESC/> example).

Expanding the entities (&amp; as an example) already transforms the
input from well-formed XML to something else. I don't see the possible
presence of \027 in here as any more risky than a serial cable's
ability to carry that same octet.

Jul 20 '05 #7
Andy Dingley wrote:
On Sat, 24 Jan 2004 02:21:44 +0000, Peter Flynn <pe***@silmaril.ie>
wrote:

You really, *really*, REALLY don't want ESC in your output stream, ever,
unless you are writing a device controller.

But what if I am ?

 is a good "XML-like" solution to handling these potentially
volatile characters. Represented as an entity, it ain't going nowhere
(equally for your <ESC/> example).

Expanding the entities (&amp; as an example) already transforms the
input from well-formed XML to something else. I don't see the possible
presence of \027 in here as any more risky than a serial cable's
ability to carry that same octet.


In fact, generating *XML* and sending it directly to a device that
expects ESCs makes little sense. However, it's perfectly plausible to
use XSLT's text output method to produce this kind of output. Right now,
this doesn't work out-of-the-box.

One approach is to define placeholders such as <esc/> and have a special
output method to translate those (I think many Java based XSLT engines
allow you to define custom output methods).

This issue may also get solved by XML 1.1
(<http://www.w3.org/TR/xml11/#sec-xml11>). Is anybody aware of changes
in XSLT 2.0?

Julian
Jul 20 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

18 posts views Thread by Steve Litvack | last post: by
4 posts views Thread by Guadala Harry | last post: by
15 posts views Thread by pkaeowic | last post: by
131 posts views Thread by Lawrence D'Oliveiro | last post: by
3 posts views Thread by qilin | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.