# in XML string

D

dmckeon

I have an XML string that contains a "#" character. I am passing the
string to a JSP page and it reads up to the character before the "#"
but nothing after that. I am new to this, so I was wondering if "#" is
an escape sequence and if there is a way to get it into my string.

Thanks,
Dan
 
M

Martin Honnen

I have an XML string that contains a "#" character. I am passing the
string to a JSP page and it reads up to the character before the "#"
but nothing after that. I am new to this, so I was wondering if "#" is
an escape sequence and if there is a way to get it into my string.

XML uses the ampersand '&' to start character or entity references. '#'
is not used as an escape character in XML.
 
D

dmckeon

Martin said:
XML uses the ampersand '&' to start character or entity references. '#'
is not used as an escape character in XML.

Thanks for the reply. Do you know why my string might be getting cut
off at "#"?
 
M

Martin Honnen

Do you know why my string might be getting cut
off at "#"?

No idea really, you will need to provide more details on what it looks
like and what "pass string to JSP page" means. It could be that you pass
the string in a URL and in the URL the '#' has a special meaning as a
fragment identifier.
 
A

Andy Dingley

Thanks for the reply. Do you know why my string might be getting cut
off at "#"?

What do you mean by "passing the string to a JSP page" ?

If you mean "I use the string as a HTTP URL", which seems unrelated to
XML but very likely as something to pass to JSP, then the # character
is significant in HTTP. It marks the end of the "page" in the URL and
the beginning of the "fragment identifier". Although they're both
available to JSP, they'll be split up.

It sounds like you need to think a bit more carefully about the
application design here - we don't have enough information to go on
this much alone. Why do you want to pass a string at all ? What is
this string, a URL or an opaque parameter that you're passing (for
instance) as a query parameter? If it's a string, then use some sort of
URLEncode() function (most web server programming languages have one)
to map '#' onto '%23' (and also ' ' to '%20' etc.).

I doubt very much if this problem is XML related.
 
D

dmckeon

Andy Dingley said:
What do you mean by "passing the string to a JSP page" ?

If you mean "I use the string as a HTTP URL", which seems unrelated to
XML but very likely as something to pass to JSP, then the # character
is significant in HTTP. It marks the end of the "page" in the URL and
the beginning of the "fragment identifier". Although they're both
available to JSP, they'll be split up.

It sounds like you need to think a bit more carefully about the
application design here - we don't have enough information to go on
this much alone. Why do you want to pass a string at all ? What is
this string, a URL or an opaque parameter that you're passing (for
instance) as a query parameter? If it's a string, then use some sort of
URLEncode() function (most web server programming languages have one)
to map '#' onto '%23' (and also ' ' to '%20' etc.).

I doubt very much if this problem is XML related.

I think you're correct. It doesn't appear to be an XML issue. I'm
just trying to put together a quick demo, so I was passing the XML
string in the URL using a question mark. It's not how I would deploy
it, but I thought it would be easiest for the demo. I will restructure
it. Thank you all for your input.

Dan
 
J

Joe Kesselman

If you're using SAX, remember that contiguous text may be delivered as
several successive calls to characters(). ("Why does SAX cut off my
text" is probably the single most frequently asked question...)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,233
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top