TheVoicedElk
TheVoicedElk

Reputation: 31

SQL Xquery implementation in weblogic

I recently was involved with upgrading an weblogic environment from version 10.3.3.0 to 10.3.6.0. Both were hosting the same version of OSB and after copying all the code over we encountered an issue. Everything worked apart from what we eventually found to be a piece of xquery. The XQuery in question grabbed a token from a database so we could send off a request via a business service and the token that we retrieved from a database was incorrectly formatted. The XQuery in question was a fn-bea:execute-sql command. Where the old environment created a token formatted the token with carriage returns, the new environment ran the same code and created a token that looked like this:

54686973206973206120746F6B656E0D#&13;
0A54686973206973206120746F6B656E#&13;
0D0A54686973206973206120746F6B65#&13;
6E0D0A54686973206973206120746F6B#&13;
656E0D0A54686973206973206120746F#&13;
6B656E0D0A5468697320697320612074#&13;

The token had an extra #&13; at the end of each line before the carriage return (I checked with notepad++ and saw the carriage return character after this). Now I know that #&13; is the ASCII code for a carriage return and I used a little bit of xquery formatting to remove them as a workaround. The XQuery in question was:

fn:replace(xs:token(TOKEN), " " , "
")

Where token is the variable that I put the results of the sql function into.

However I'm wondering what caused this? has this xquery functionality been removed from the newer version of weblogic? I couldn't see anything in the weblogic change logs that directly related to this.

Also is there a cleaner workaround than formatting the string as a token to remove the #&13; along with the carriage return and then re-adding the carriage returns in place of the spaces that have been added?

Thanks, TheVoicedElk

Upvotes: 2

Views: 117

Answers (1)

Trent Bartlem
Trent Bartlem

Reputation: 2253

The token had an extra #&13; at the end of each line before the carriage return

Not quite.


 is carriage return (aka \r or &#xD).


 is line feed (aka \n or &#xA).

So, the xquery engine translates the \n into an actual newline character that Notepad understands, but keeps the carriage return encoded as an entity.

If you want to remove that, I guess replace($token, '\r','') would work. You keep the \n but strip the \r.

Upvotes: 1

Related Questions