Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

java and xml

2 views
Skip to first unread message

JimmyMac

unread,
Jul 13, 2001, 10:26:32 AM7/13/01
to
While parseing an xml document( sax parser ), trying to replace ' | ' with
' & ' , it finds the pipe, but won't replace with amper.

public void characters (char ch[], int start, int length)
{
if( choice_text )
{
choice = new String(ch).substring(start,start + length);

// choice.replace( ' | ' , ' & ' ); // didn't work

XMLChoices[XMLquestion_text_counter][choice_counter] = choice;

}
//..............
for (int i = start; i < start + length; i++) {

switch (ch[i]) {
case '|':

ch[i] = '&';

break;

any help?
Jim


Roger Lindsjö

unread,
Jul 13, 2001, 12:17:33 PM7/13/01
to
JimmyMac wrote:
>
> While parseing an xml document( sax parser ), trying to replace ' | ' with
> ' & ' , it finds the pipe, but won't replace with amper.

Remember, Strings are immutable (ie, can not change).

>
> public void characters (char ch[], int start, int length)
> {
> if( choice_text )
> {
> choice = new String(ch).substring(start,start + length);
>
> // choice.replace( ' | ' , ' & ' ); // didn't work

It does work, choice.replace returns a new string with the replced
characters, but you just throw this result away.

> XMLChoices[XMLquestion_text_counter][choice_counter] = choice;
>
> }
> //..............
> for (int i = start; i < start + length; i++) {
>
> switch (ch[i]) {
> case '|':
>
> ch[i] = '&';
>
> break;

Roger Lindsjö

JimmyMac

unread,
Jul 13, 2001, 12:33:17 PM7/13/01
to

"Roger Lindsjö" <roger....@halebop.net> wrote in message
news:3B4F1F1D...@halebop.net...

> JimmyMac wrote:
> >
> > While parseing an xml document( sax parser ), trying to replace ' | '
with
> > ' & ' , it finds the pipe, but won't replace with amper.
>
> Remember, Strings are immutable (ie, can not change).
>
> >
> > public void characters (char ch[], int start, int length)
> > {
> > if( choice_text )
> > {
> > choice = new String(ch).substring(start,start + length);
> >
> > // choice.replace( ' | ' , ' & ' ); // didn't work
////////////////////////////////////////////////////////////////////////////
/////////////////////////////////
DOH!!!! newChoice = choice.replace( ' | ' , ' & ' );
> XMLChoices[XMLquestion_text_counter][choice_counter] =
newChoice
////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////

Driver

unread,
Jul 16, 2001, 9:20:26 PM7/16/01
to
I have downloaded the Orion JSP (J2EE compliant) server and am trying to do
CGI-type work with it. At a standstill. I have the WROX JSP book, and it
mentions servlet-based processing to complete work once done with CGI, and
the book leaves me hanging there.

Can anyone advise?

Thanks


Chris Smith

unread,
Jul 16, 2001, 9:32:30 PM7/16/01
to
"Driver" <betsam...@mindspring.com> wrote ...

> I have downloaded the Orion JSP (J2EE compliant) server and am trying to
do
> CGI-type work with it. At a standstill. I have the WROX JSP book, and it
> mentions servlet-based processing to complete work once done with CGI, and
> the book leaves me hanging there.

If it's a JSP book, then certainly it says more about using both servlets
and JSPs than you let on. If not, return it and buy a real book.

If your question is more specific than that, please ask your specific
question.

Chris Smith


0 new messages