MQSeries.net
 FAQÂ Â

 RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

xmlnsc parser adding an extra slash
Author Message
paustin_ours
 Posted: Mon Nov 13, 2017 9:14 am    Post subject: xmlnsc parser adding an extra slash

Yatiri

Joined: 19 May 2004
Posts: 626
Location: columbus,oh

 I have an input xml message that i parse in the MQinput node as xmlnsc. I see a file name field getting parsed and showing up like this with extra back slashes. \\\\hstst.mdcorp.com\\prog_fit\\testdata\\out\\testfile.txt the actual field value in the input xml is \\hstst.mdcorp.com\prog_fit\testdata\out\testfile.txt this is what i see right after the message passes through the MQInput node, this is what i see in the debugger and also in the environment variable after i store it there. not sure why it is adding the extra slash.
Vitor
 Posted: Mon Nov 13, 2017 10:16 am    Post subject: Re: xmlnsc parser adding an extra slash

Grand High Poobah

Joined: 11 Nov 2005
Posts: 25362
Location: Ohio, USA

 paustin_ours wrote: not sure why it is adding the extra slash.

Because if it didn't, \h would be an escaped character. So would \p, \t, \o and \t (again). So it escapes it with a \ so the \ becomes an escaped slash.

See here

The time to worry is when the extra don't do away when it's serialized again.
_________________
Honesty is the best policy.
Insanity is the best defence.
Vitor
 Posted: Mon Nov 13, 2017 10:19 am    Post subject:

Grand High Poobah

Joined: 11 Nov 2005
Posts: 25362
Location: Ohio, USA

 Also, and perhaps critically, it's not file:\\\\hstst.mdcorp.com\prog_fit\testdata\out\testfile.txt so it's not really a file name. Except to Windoze. Like I said, the additional characters should disappear when you reserialize it._________________Honesty is the best policy. Insanity is the best defence.
paustin_ours
 Posted: Mon Nov 13, 2017 10:43 am    Post subject:

Yatiri

Joined: 19 May 2004
Posts: 626
Location: columbus,oh

 how do i reserialize it, i am getting the input as xmlnsc, then storing that value in an environment variable. Then using it to write a JSON outputRoot. all the while the \\\\ and \\ remains. I got to cast as CHARACTER perhaps?
Vitor
 Posted: Mon Nov 13, 2017 10:58 am    Post subject:

Grand High Poobah

Joined: 11 Nov 2005
Posts: 25362
Location: Ohio, USA

 paustin_ours wrote: I got to cast as CHARACTER perhaps?

I'd be somewhat astonished if it wasn't already a character.

I think your problem is that JSON has different rules to XML, so when it's reserialized by whatever's doing the output into JSON (I assume a REST or HTTP node) the extras are acceptable.

An interesting experiment would be to try outputting it as an XMLNSC payload - this would at least prove the problem is what I think it is.

You may need a spot of code to fix this. Unless someone comes along with a better idea.
_________________
Honesty is the best policy.
Insanity is the best defence.
fjb_saper
 Posted: Mon Nov 13, 2017 11:16 am    Post subject:

Grand Poobah

Joined: 18 Nov 2003
Posts: 19824
Location: LI,NY

Vitor wrote:
 paustin_ours wrote: I got to cast as CHARACTER perhaps?

I'd be somewhat astonished if it wasn't already a character.

I think your problem is that JSON has different rules to XML, so when it's reserialized by whatever's doing the output into JSON (I assume a REST or HTTP node) the extras are acceptable.

An interesting experiment would be to try outputting it as an XMLNSC payload - this would at least prove the problem is what I think it is.

You may need a spot of code to fix this. Unless someone comes along with a better idea.

Let's be honest here: If you did not want the \\ you should have use a java representation with forward slashes instead.

So the path would have been //hstst.mdcorp.com/prog_fit/testdata/out/testfile.txt and you would not see any escape characters.

However as long as you are looking at a file and a java representation of the windows path all \ must be escaped i.e. \\ will look like \\\\ and \ like \\
In other words what you see is normal and expected...
Have fun
_________________

Last edited by fjb_saper on Mon Nov 13, 2017 11:17 am; edited 1 time in total
paustin_ours
 Posted: Mon Nov 13, 2017 11:16 am    Post subject:

Yatiri

Joined: 19 May 2004
Posts: 626
Location: columbus,oh

 again all am doing is parsing the incoming xml as xmlnsc in the mq input node. then storing this field in environment variable. then i do OutputRoot.JSON.Data.field = env.blah.blah where i had stored the file name. this output root is coming out with \\\\ and \\ i will try outputroot as xml see how it come out.
fjb_saper
 Posted: Mon Nov 13, 2017 11:20 am    Post subject:

Grand Poobah

Joined: 18 Nov 2003
Posts: 19824
Location: LI,NY

 paustin_ours wrote: again all am doing is parsing the incoming xml as xmlnsc in the mq input node. then storing this field in environment variable. then i do OutputRoot.JSON.Data.field = env.blah.blah where i had stored the file name. this output root is coming out with \\\\ and \\ i will try outputroot as xml see how it come out.

Don't bother it is a windows path and is as it should be. Only humans can dissotiate the \ character from the backslash \ ... Machines do not hence the double up on the \\.
It is as it should be. If you don't want the confusion use the Unix path version with forward slashes. Java (and I believe JSON) will accept it as a file path.
Have fun
_________________
Vitor
 Posted: Mon Nov 13, 2017 11:44 am    Post subject:

Grand High Poobah

Joined: 11 Nov 2005
Posts: 25362
Location: Ohio, USA

 fjb_saper wrote: Don't bother it is a windows path and is as it should be.

 Vitor wrote: it's not really a file name. Except to Windoze

_________________
Honesty is the best policy.
Insanity is the best defence.
rekarm01
 Posted: Mon Nov 13, 2017 2:33 pm    Post subject: Re: xmlnsc parser adding an extra slash

Grand Master

Joined: 25 Jun 2008
Posts: 1322

 paustin_ours wrote: not sure why it is adding the extra slash.

The JSON parser is adding the extra backslash characters, not the XMLNSC parser. That is a requirement for JSON strings.
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First
 Page 1 of 1

 Jump to: Select a forum General Discussion----------------Read First for All New to WebSphere - Only Moderators Post HereGeneral DiscussionWebSphere Technologies FAQNews/UpdatesLinksJob PostingsJob SeekersGeneral Forums Information Requirements, Wishlists & Enhancement Requests----------------RFEs - Requirements, Wishlists & Enhancement Requests - Open Forum Sponsored Forums----------------Cressida Technology IBM MQ Support----------------General IBM MQ SupportIBM MQ Installation/Configuration SupportClusteringIBM MQ Telemetry / Low Latency Messaging / EveryplaceMainframe, CICS, TXSeriesiSeries, OpenVMS, HP-NSSIBM MQ Performance MonitoringIBM MQ Security IBM MQ Development----------------IBM MQ Java / JMSIBM MQ API SupportMultiphase CommitUser Exits WebSphere Message Broker----------------WebSphere Message Broker SupportWMB Patterns Repository - Available for Download WebSphere Application Server----------------WebSphere Application Server Web Services----------------WebSphere DataPower Products that use IBM MQ----------------Workflow Engines - IBM MQ Workflow & Business Process ChoreographerWebSphere Process Server (WID/WPS/WAS+)WebSphere Interchange Server + AdaptersIBM MQ File Transfer Edition Resources, Files, Samples, Archives, Misc----------------Files and Code SamplesArchives - AllChallenge Forum

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot vote in polls in this forum
Protected by Anti-Spam ACP

Theme by Dustin Baccetti