Author |
Message
|
KIT_INC |
Posted: Mon Mar 29, 2010 6:44 am Post subject: Accessing Input Namespace |
|
|
Knight
Joined: 25 Aug 2006 Posts: 589
|
I am using Broker V61 on windows. I have to create an XML output from a field in the XML input message.
The INput message is like
<?xml version="1.0" encoding="UTF-8"?>
<CCWEB DocVersion="4.0" Created="03/1/2010 8:51:44 AM" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns="x-schema:CCWEBSchema.xml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="x-schema:CCWEBSchema.xml C:\DOCUME~1\CCWEB.xsd">
<Categories>
<Category CategoryID="1000001" Name="HOTEL SERVICE" />
</Categories>
</CCWEB>
The flow is a simple MQINPUT-TRACE-COMPUTE-MQOUTPUT
The Input is just using XMLNS because I have no schema.
My ESQL is like
DECLARE SP1 NAMESPACE 'x-schema:CCWEBSchema.xml';
SET OutputRoot.XMLNS.NS_TEST.DATA=InputRoot.XMLNS.SP1:CCWEB.SP1:Categories.SP1:Category.Name;
This works and the output looks like
<NS_TEST DATA="HOTEL SERVICE"/>
But my ESQL has to know the NAMESPACE ahead of time. Can I get the namespace dynamically from Input?
I am new to Namespace. I am not sure if I am asking stupid question. If I am right the namspace comes from the XML decl of the incoming message. But I have a hard trying to figure out how to pick up the Namespace information from InputRoot.XMLNS
Looking at the trace output, the root element is already qualified with the NS (x-schema:CCWEBSchema.xml:CCWEB ).
Is the Input data correct ? If so, am I asking for something not normal practice?
This is what shows in the TRACE
(0x01000010:ParserRoot):XMLNS = ( ['xmlns' : 0x771a4b8]
(0x05000018:XmlDecl ):XML = (
(0x06000011:Version ): = '1.0' (CHARACTER)
(0x06000012:Encoding): = 'UTF-8' (CHARACTER)
)
(0x06000002:WhiteSpace): = '
' (CHARACTER)
(0x01000000:Element )x-schema:CCWEBSchema.xml:CCWEB = (
(0x03000000:Attribute ):DocVersion = '4.0' (CHARACTER)
(0x03000000:Attribute ):Created = '12/1/2009 8:51:44 AM' (CHARACTER)
(0x07000012:NamespaceDecl)xmlns:msxsl = 'urn:schemas-microsoft-com:xslt' (CHARACTER)
(0x07000012:NamespaceDecl):xmlns = 'x-schema:CCWEBSchema.xml' (CHARACTER)
(0x07000012:NamespaceDecl)xmlns:xsi = 'http://www.w3.org/2001/XMLSchema-instance' (CHARACTER)
(0x03000000:Attribute )http://www.w3.org/2001/XMLSchema-instance:schemaLocation = 'x-schema:CCWEBSchema.xml C:\DOCUME~1\CCWEB.xsd' (CHARACTER)
(0x02000000:pcdata ): = '
' (CHARACTER)
(0x01000000:Element )x-schema:CCWEBSchema.xml:Categories = (
(0x02000000:pcdata ): = '
' (CHARACTER)
(0x01000000:Element)x-schema:CCWEBSchema.xml:Category = (
(0x03000000:Attribute):CategoryID = '1000001' (CHARACTER)
(0x03000000:Attribute):Name = 'HOTEL SERVICE' (CHARACTER)
)
(0x02000000:pcdata ): = '
' (CHARACTER)
)
(0x02000000:pcdata ): = '
' (CHARACTER)
)
)
); |
|
Back to top |
|
 |
Vitor |
Posted: Mon Mar 29, 2010 6:51 am Post subject: Re: Accessing Input Namespace |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
KIT_INC wrote: |
The flow is a simple MQINPUT-TRACE-COMPUTE-MQOUTPUT
The Input is just using XMLNS because I have no schema. |
That's no reason not to be using XMLNSC
KIT_INC wrote: |
Can I get the namespace dynamically from Input? |
Try this _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
KIT_INC |
Posted: Mon Mar 29, 2010 7:40 am Post subject: |
|
|
Knight
Joined: 25 Aug 2006 Posts: 589
|
I tried.
-FIELDNAMESPACE--(--FieldReference--)
But the FieldReference without specifying the Namespace result in
" Failed to navigate to path element number '3' because it does not exist."
This is just a test run, I'll switch to XMLNSC when I start the real coding. I think what I have seen so far should makes no difference if I am using XMLNSC instead of XMLNS. |
|
Back to top |
|
 |
Vitor |
Posted: Mon Mar 29, 2010 7:49 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
KIT_INC wrote: |
" Failed to navigate to path element number '3' because it does not exist." |
Well clearly you have to try to find the namespace of an element that exists.
KIT_INC wrote: |
This is just a test run, I'll switch to XMLNSC when I start the real coding. I think what I have seen so far should makes no difference if I am using XMLNSC instead of XMLNS. |
Wrong. XMLNSC uses different constants, so if you're trying to navigate the message tree (to locate an element and determine it's namespace for instance) you have to use the right constants.
You'll also find XMLNSC easier to use for what you're trying to do. There's one key difference in logic terms between XNLNS & XMLNSC....  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
smdavies99 |
Posted: Mon Mar 29, 2010 7:50 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
A simple search of this forum gives this
http://www.mqseries.net/phpBB2/viewtopic.php?t=52507
Perhaps this is what you want? _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
Vitor |
Posted: Mon Mar 29, 2010 7:53 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
Throwing fish?  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
fjb_saper |
Posted: Mon Mar 29, 2010 8:11 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
As you found out you can move a reference around and not worry about namespace, and discover it using the fieldnamespace function.
You can also use a wildcard for the namespace, to substitute for any namespace... You cannot do this while creating the tree, only when reading the tree... Look it up in the manuals.
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
KIT_INC |
Posted: Tue Mar 30, 2010 7:48 am Post subject: |
|
|
Knight
Joined: 25 Aug 2006 Posts: 589
|
Using wild card and then FIELDNAMESPACE works. Thanks a lot. |
|
Back to top |
|
 |
|