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: 667 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. |
|
Back to top |
|
 |
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: 26093 Location: Texas, 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. |
|
Back to top |
|
 |
Vitor |
Posted: Mon Nov 13, 2017 10:19 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, 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. |
|
Back to top |
|
 |
paustin_ours |
Posted: Mon Nov 13, 2017 10:43 am Post subject: |
|
|
Yatiri
Joined: 19 May 2004 Posts: 667 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? |
|
Back to top |
|
 |
Vitor |
Posted: Mon Nov 13, 2017 10:58 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, 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. |
|
Back to top |
|
 |
fjb_saper |
Posted: Mon Nov 13, 2017 11:16 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 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  _________________ MQ & Broker admin
Last edited by fjb_saper on Mon Nov 13, 2017 11:17 am; edited 1 time in total |
|
Back to top |
|
 |
paustin_ours |
Posted: Mon Nov 13, 2017 11:16 am Post subject: |
|
|
Yatiri
Joined: 19 May 2004 Posts: 667 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. |
|
Back to top |
|
 |
fjb_saper |
Posted: Mon Nov 13, 2017 11:20 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 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  _________________ MQ & Broker admin |
|
Back to top |
|
 |
Vitor |
Posted: Mon Nov 13, 2017 11:44 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, 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. |
|
Back to top |
|
 |
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: 1415
|
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. |
|
Back to top |
|
 |
|