Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Special characters in XML structure when prepared using String

996913Oct 20 2013

Hi,

   I am preparing an XML structure using 'String'. I print the prepared XML structure in the server log. Issue is that I am seeing extra characters([[ and ]]) that I am not printing.

Please let me know how to get rid of those.

Code Excerpt

--------------------

        String xmlHeader = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>";

        String lsb_xmlcon = xmlHeader;

        logger.info("ReqXMLString Process  1  --->" + lsb_xmlcon);

        lsb_xmlcon = lsb_xmlcon +("\n");

        logger.info("ReqXMLString Process  1.1  --->" + lsb_xmlcon);

        lsb_xmlcon = lsb_xmlcon +("<REQUEST>");

        lsb_xmlcon = lsb_xmlcon +("\n");

        logger.info("ReqXMLString Process  1.2  --->" + lsb_xmlcon);

Log

-----

ReqXMLString Process  1  ---><?xml version="1.0" encoding="utf-8" ?>

ReqXMLString Process  1.1  ---><?xml version="1.0" encoding="utf-8" ?>[[


]]

ReqXMLString Process  1.2  ---><?xml version="1.0" encoding="utf-8" ?>[[

<REQUEST>

]]

Thanks,

Message was edited by: 996913 This issue is observed only while running the code in server, not from Jdev. When we append the additional tags without new line character, "\n", there are no extra characters being added. Also, in other case also. where we used "Marshaller" to prepare the XML, we have seen this issue. After we set the below property to false, we got rid of the extra characters.                         jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, false); Apparently the insertion of new line when the code runs on server(Weblogic 10.3.6.0) is creating the issue. Please let me know if anyone has come across a similar scenario. Thanks,

Comments

Kalpataru

Hi @"BPeaslandDBA",

Very nice document.

One doubt.

I do not understand the line.

The forward slash after a single SQL statement will cause that SQL command to execute twice.

How to test it ?

Why because when i want to test the following command in SQL * Plus it is showing error.

select sysdate from dual; /

                        *

ERROR at line 1:

ORA-00911: invalid character

How to test that the statement will execute twice ?

Gaz in Oz

Hi @"BPeaslandDBA",

Very nice document.

One doubt.

I do not understand the line.

The forward slash after a single SQL statement will cause that SQL command to execute twice.

How to test it ?

Why because when i want to test the following command in SQL * Plus it is showing error.

select sysdate from dual; /

                        *

ERROR at line 1:

ORA-00911: invalid character

How to test that the statement will execute twice ?

The forward slash is a special character in sqlplus and must appear on a line of it's own. It runs what ever is currently in the sqlplus buffer.

Easiest way to show that behavior is with a sql file.

$ host cat twice.sqlselect sysdate from dual;/SQL> @twiceSYSDATE-------------------2017-07-22 15:56:26SYSDATE-------------------2017-07-22 15:56:26SQL>
Kalpataru

The forward slash is a special character in sqlplus and must appear on a line of it's own. It runs what ever is currently in the sqlplus buffer.

Easiest way to show that behavior is with a sql file.

$ host cat twice.sqlselect sysdate from dual;/SQL> @twiceSYSDATE-------------------2017-07-22 15:56:26SYSDATE-------------------2017-07-22 15:56:26SQL>

Thanks @"Gaz in Oz"  for your explanation.

BPeaslandDBA

Hi @"BPeaslandDBA",

Very nice document.

One doubt.

I do not understand the line.

The forward slash after a single SQL statement will cause that SQL command to execute twice.

How to test it ?

Why because when i want to test the following command in SQL * Plus it is showing error.

select sysdate from dual; /

                        *

ERROR at line 1:

ORA-00911: invalid character

How to test that the statement will execute twice ?

@"Gaz in Oz" explained it nicely. The slash needs to be on its own line. You had it on the same line. So enter any SQL statement. Then enter a slash on the next line. In SQL*Plus, that statement will be executed twice.

Cheers,
Brian

Solomon Yakobson

I think you should add section explaining semi-colon & slash use when PL/SQL is used within SQL statement. Type declarations and function in with clause in 12c.

SY.

user3263929

Hi, thank you for your document.

One question : can't we generalize the use of the forward slash ? Like this :

----

select count(*) from api_log

/

----

(the semi-colon is omitted)

Thanks.

BluShadow

Hi, thank you for your document.

One question : can't we generalize the use of the forward slash ? Like this :

----

select count(*) from api_log

/

----

(the semi-colon is omitted)

Thanks.

See page 3 "When not to use a slash".  It's possible to use a slash in many of those circumstances instead of using the semicolon, but as the "/" is often specific to certain tools, such as SQL*Plus, it is better to consider the semicolon to be the statement terminator as best practice and only use a "/" where needed.

1 - 7
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Nov 17 2013
Added on Oct 20 2013
0 comments
835 views