Author |
Message
|
kirank |
Posted: Wed May 13, 2009 10:27 am Post subject: Namespace prefix using ESQL |
|
|
 Centurion
Joined: 10 Oct 2002 Posts: 136 Location: California
|
I have a compute node where I am declaring namespace using ESQL as
DECLARE sh NAMESPACE 'http://www.unece.org/cefact/namespaces/StandardBusinessDocumentHeader';
However at run time Broker puts the prefix as NS1 instead of sh I declared. Is there any way to force what we want rather than a numbered prefix?
Regards
Kiran |
|
Back to top |
|
 |
mqjeff |
Posted: Wed May 13, 2009 11:12 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
DECLARE NAMESPACE tells ESQL how to interpret your namespace qualifier.
The only way to control namespace prefixes in XML is to specify them in the XML document. |
|
Back to top |
|
 |
recallsunny |
Posted: Wed May 13, 2009 11:38 am Post subject: |
|
|
 Disciple
Joined: 15 Jun 2005 Posts: 163 Location: Massachusetts
|
Why would you want to force a certain prefix instead of the standard one generated by Broker? It beats the purpose of XML & Namespaces imo. |
|
Back to top |
|
 |
broker_new |
Posted: Wed May 13, 2009 12:28 pm Post subject: |
|
|
 Yatiri
Joined: 30 Nov 2006 Posts: 614 Location: Washington DC
|
Post the ESQL please, will be easy to reply with the solution _________________ IBM ->Let's build a smarter planet |
|
Back to top |
|
 |
mqjeff |
Posted: Wed May 13, 2009 12:33 pm Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
The solution is to set an XML NameSpace Declaration in the output XML document. |
|
Back to top |
|
 |
kirank |
Posted: Wed May 13, 2009 12:38 pm Post subject: |
|
|
 Centurion
Joined: 10 Oct 2002 Posts: 136 Location: California
|
I know most XML validators should be able handle namespace as long as value is right and the prefix can be anything. The data is sent to External Party and I am not sure how they parse this XML. But they came back to me saying the prefix is not right.
After declaring the Namespace prefix I use it in ESQL as below to set Root tag.
SET OutputRoot.XMLNS.sh:StandardBusinessDocument.sh:StandardBusinessDocumentHeader.sh:HeaderVersion = '1.0';
This produces Output XML root tag as below
<NS1:StandardBusinessDocument xmlns:NS1="http://www.unece.org/cefact/namespaces/StandardBusinessDocumentHeader">
I think their system should be able to handle it. They have not yet loaded it. But I am being proactive and want to know if there is any way of enforcing a value we want.
Regards
Kiran |
|
Back to top |
|
 |
recallsunny |
Posted: Wed May 13, 2009 12:43 pm Post subject: |
|
|
 Disciple
Joined: 15 Jun 2005 Posts: 163 Location: Massachusetts
|
The brute way of forcing this is to change the domain to non XMLNSC so that broker doesn't acknowledge the namespace declarations. By doing this, you're choosing a less efficient parser. |
|
Back to top |
|
 |
broker_new |
Posted: Wed May 13, 2009 12:50 pm Post subject: |
|
|
 Yatiri
Joined: 30 Nov 2006 Posts: 614 Location: Washington DC
|
I agree in this case but when using namespaces certain times we must use "XMLNS" domain.
kirank use this...
SET OutputRoot.XMLNS.sh:StandardBusinessDocument.(XML.NamespaceDecl)xmlns:"sh" = 'http://www.unece.org/cefact/namespaces/StandardBusinessDocumentHeader';
SET OutputRoot.XMLNS.sh:StandardBusinessDocument.sh:StandardBusinessDocumentHeader.sh:HeaderVersion = '1.0'; _________________ IBM ->Let's build a smarter planet |
|
Back to top |
|
 |
mqjeff |
Posted: Wed May 13, 2009 12:54 pm Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
broker_new wrote: |
I agree in this case but when using namespaces certain times we must use "XMLNS" domain. |
Always use XMLNSC. |
|
Back to top |
|
 |
broker_new |
Posted: Wed May 13, 2009 1:06 pm Post subject: |
|
|
 Yatiri
Joined: 30 Nov 2006 Posts: 614 Location: Washington DC
|
|
Back to top |
|
 |
rekarm01 |
Posted: Wed May 13, 2009 1:15 pm Post subject: Re: Namespace prefix using ESQL |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 1415
|
mqjeff wrote: |
broker_new wrote: |
I agree in this case but when using namespaces certain times we must use "XMLNS" domain. |
Always use XMLNSC. |
Always? The WMB documentation offers slightly different advice:
Quote: |
Tip: If you require message tree to conform as closely as possible to the XML data model, perhaps because you are using certain XPath expressions to access the message tree, use the XMLNS domain. |
Please elaborate. |
|
Back to top |
|
 |
recallsunny |
Posted: Wed May 13, 2009 1:18 pm Post subject: |
|
|
 Disciple
Joined: 15 Jun 2005 Posts: 163 Location: Massachusetts
|
broker_new wrote: |
I remember i had a problem with namespaces longtime back and tried all the possible ways using XMLNSC but didn't work at all..switched to XMLNS worked like a charm.
|
The XMLNSC parser has a new architecture that gives significant performance improvements over the XMLNS and XML parsers
XMLNSC is the way to go. |
|
Back to top |
|
 |
broker_new |
Posted: Wed May 13, 2009 1:23 pm Post subject: |
|
|
 Yatiri
Joined: 30 Nov 2006 Posts: 614 Location: Washington DC
|
I totally agree with you... but can you tell me how you would resolve this using XMLNSC parser.
The output should look like this.
<Information xmlns="" xmlns="http://www.ibm.com">
<userId>34566775</userId>
</Information > _________________ IBM ->Let's build a smarter planet |
|
Back to top |
|
 |
mqjeff |
Posted: Wed May 13, 2009 1:35 pm Post subject: Re: Namespace prefix using ESQL |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
rekarm01 wrote: |
mqjeff wrote: |
broker_new wrote: |
I agree in this case but when using namespaces certain times we must use "XMLNS" domain. |
Always use XMLNSC. |
Always? The WMB documentation offers slightly different advice:
Quote: |
Tip: If you require message tree to conform as closely as possible to the XML data model, perhaps because you are using certain XPath expressions to access the message tree, use the XMLNS domain. |
Please elaborate. |
Fine.
Always use XMLNSC unless you know exactly why you aren't using it. |
|
Back to top |
|
 |
kirank |
Posted: Wed May 13, 2009 4:14 pm Post subject: |
|
|
 Centurion
Joined: 10 Oct 2002 Posts: 136 Location: California
|
Thanks broker_new. Your solution worked.
Regards
Kiran |
|
Back to top |
|
 |
|