ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum IndexWebSphere Message Broker Supportxmlnsc attribute name xmlns

Post new topicReply to topic Goto page 1, 2  Next
xmlnsc attribute name xmlns View previous topic :: View next topic
Author Message
paustin_ours
PostPosted: Thu Feb 16, 2012 5:24 am Post subject: xmlnsc attribute name xmlns Reply with quote

Yatiri

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

I am creating a xmlnsc namespace aware xml output. The name space creation works fine. I also need to create a tag with attribute name xmlns

when i say

(XMLNSC.Attribute)xmlns =

i get an error saying that i am trying to use default namespace. Looks like the xmlns is bieng considered as a default namespace while it is writing the xml out.

I also tried

(XMLNSC.Attribute)"xmlns" =

Still same error. Any thoughts on how to get around this. Please help!!
Back to top
View user's profile Send private message Yahoo Messenger
mqsiuser
PostPosted: Thu Feb 16, 2012 6:05 am Post subject: Re: xmlnsc attribute name xmlns Reply with quote

Yatiri

Joined: 15 Apr 2008
Posts: 627
Location: Germany

xmlns is a "reserved attribute". Note that this is from the W3C-Standard:

http://www.w3.org/TR/REC-xml-names/ wrote:
Definition: A namespace (or more precisely, a namespace binding) is declared using a family of reserved attributes. Such an attribute's name must either be xmlns or begin xmlns:. These attributes, like any other XML attributes, may be provided directly or by default.


I also tried to set it (as you do) manually... then... I gave up. Parsers claim the definition of default namespaces and namespace prefixes for them, with little(?) chance to take control over it yourself. Often they put it into the message in a way that you do not want and probably you can't come about it - probably you can, someone else to comment, please!

Anyway, I guess you need to define NAMESPACEs in your code and you can not create directly an "xmlns"-attribute or xmlns-prefixes as you would with "normal" xml-attributes (like you try here). In the end the (out-)parser puts in (xmlns and) xmlns-prefixes where he thinks it is appropriate
_________________
Just use REFERENCEs
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Thu Feb 16, 2012 6:47 am Post subject: Re: xmlnsc attribute name xmlns Reply with quote

Grand High Poobah

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

paustin_ours wrote:
I am creating a xmlnsc namespace aware xml output. The name space creation works fine. I also need to create a tag with attribute name xmlns

when i say

(XMLNSC.Attribute)xmlns =

i get an error saying that i am trying to use default namespace. Looks like the xmlns is bieng considered as a default namespace while it is writing the xml out.

I also tried

(XMLNSC.Attribute)"xmlns" =

Still same error. Any thoughts on how to get around this. Please help!!


What happens when you drop the space between xmlns and = ?
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Vitor
PostPosted: Thu Feb 16, 2012 7:33 am Post subject: Re: xmlnsc attribute name xmlns Reply with quote

Grand High Poobah

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

paustin_ours wrote:
Any thoughts on how to get around this.


I use

Code:
CREATE LASTCHILD OF OutputRoot TYPE XMLNSC.DoubleNamespaceDecl NAME 'xmlns' VALUE foo;


where foo is a NAMESPACE I've declared (or has been declared for me):

Code:
DECLARE foo NAMESPACE 'https://schemas.bar.com/lottery/EuromillionWinners';


Other methods are undoubtably available and may be better.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
kimbert
PostPosted: Thu Feb 16, 2012 1:35 pm Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Quote:
Anyway, I guess you need to define NAMESPACEs in your code and you can not create directly an "xmlns"-attribute or xmlns-prefixes as you would with "normal" xml-attributes (like you try here). In the end the (out-)parser puts in (xmlns and) xmlns-prefixes where he thinks it is appropriate
This is a very misleading comment - and not likely to be very helpful to future readers of this thread.
All of the XML parsers provided by message broker allow you to control the namespace prefixes in the output XML.
XMLNS and XMLNSC allow you to put xmlns attributes whenever and wherever you like. There are code examples in the info center showing exactly how to do this - please refer to them.

Vitor's code is a little verbose, but will work. The info center demonstrates the easier way to do it.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Thu Feb 16, 2012 2:57 pm Post subject: Reply with quote

Grand High Poobah

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

Bingo!

@ paustin_ours Your problem was trying to do a namespace declaration with an attribute declaration. It may look the same to you but surely you realize the broker thinks differently...

Code:
XMLNSC.Namespace
is probably what you should have used...
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
mqsiuser
PostPosted: Thu Feb 16, 2012 7:12 pm Post subject: Re: xmlnsc attribute name xmlns Reply with quote

Yatiri

Joined: 15 Apr 2008
Posts: 627
Location: Germany

mqsiuser wrote:
I also tried to set it (as you do) manually... then... I gave up. Parsers claim the definition of default namespaces and namespace prefixes for them, with little(?) chance to take control over it yourself. Often they put it into the message in a way that you do not want and probably you can't come about it - probably you can, someone else to comment, please!

[...] In the end the (out-)parser puts in (xmlns and) xmlns-prefixes where he thinks it is appropriate


I was adding to the question. Thanks Kimbert, great to know you pass through the control. Thanks for the examples (Vitor and fjb_saper) and the tipp with the infocenter!
_________________
Just use REFERENCEs
Back to top
View user's profile Send private message
paustin_ours
PostPosted: Thu Feb 16, 2012 7:46 pm Post subject: Reply with quote

Yatiri

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

Nevermind, i read it wrong. I actually need the output to have a default namespace xmlns and not an attribute.

I need the output xml of the format

<env:Header>
<env:Body>
<test xmlns="http:....">
here i am able to get the env out in the namespace

in order to get xmlns in the output i tried

DECLARE xmlns NAMESPACE '';

SET OutputRoot.XMLNSC.env:Header.env.Body.xmlns:test.(XMLNSC.NamespaceDecl)xmlns='http.....";

**************
I GET AN ERROR saying

Element must have a namespace specified if there is a default namesapce in scope. test.

*************

I do have namespace specified here xmlns:test

Not sure what i am missing. Please help!
Back to top
View user's profile Send private message Yahoo Messenger
paustin_ours
PostPosted: Thu Feb 16, 2012 7:59 pm Post subject: Reply with quote

Yatiri

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

if i specify

DECLARE xmlns NAMESPACE 'http...." [ instead of leaving it blank '' like i did initially]

i get the below output

NS1:Envelope xmlns:NS1="http...."
NS1:Header

all the env: is gone. looks like this default namespace declaration is taking precedence and my other namespcace declarations are being ignored.
Back to top
View user's profile Send private message Yahoo Messenger
fjb_saper
PostPosted: Thu Feb 16, 2012 8:12 pm Post subject: Reply with quote

Grand High Poobah

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

paustin_ours wrote:
if i specify

DECLARE xmlns NAMESPACE 'http...." [ instead of leaving it blank '' like i did initially]

i get the below output

NS1:Envelope xmlns:NS1="http...."
NS1:Header

all the env: is gone. looks like this default namespace declaration is taking precedence and my other namespcace declarations are being ignored.

<env:Header>
<env:Body>
<test xmlns="http:....">


Ok so did you define env?
Code:
DECLARE env NAMESPACE 'http....';

SET OutputRoot.XMLNSC.env:Envelope.(XMLNSC.NamespaceDecl)xmlns:env='http...';


You need to define like that any namespace that you want to keep the specific name as prefix...

Have fun
_________________
MQ & Broker admin


Last edited by fjb_saper on Thu Feb 16, 2012 8:13 pm; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail
paustin_ours
PostPosted: Thu Feb 16, 2012 8:12 pm Post subject: Reply with quote

Yatiri

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

Oops for some reason, i was not able to look at the responses until now.

I tried XMLNS.Namespace instead of NamespaceDecl but that errored out saying that XMLNS.Namespace is not a valid option.

ANyways, like i had mentioned i thought the xmlns was an attribute and then realised it is a default namespace declaration.

I am not sure how to use the CREATE LASTCHILD

i need the output of the form

<test xmlns="http...">
Back to top
View user's profile Send private message Yahoo Messenger
fjb_saper
PostPosted: Thu Feb 16, 2012 8:15 pm Post subject: Reply with quote

Grand High Poobah

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

paustin_ours wrote:
Oops for some reason, i was not able to look at the responses until now.

I tried XMLNS.Namespace instead of NamespaceDecl but that errored out saying that XMLNS.Namespace is not a valid option.

ANyways, like i had mentioned i thought the xmlns was an attribute and then realised it is a default namespace declaration.

I am not sure how to use the CREATE LASTCHILD

i need the output of the form

<test xmlns="http...">

You should not mix XML.NamespaceDecl for the XMLNS parser and XMLNSC.NamespaceDecl for the XMLNSC parser...

Try
Code:

CREATE FIRSTCHILD OF xyz TYPE XMLNSC.NamespaceDecl NAMESPACE xmlns NAME env VALUE 'http...';

CREATE FIRSTCHILD OF test TYPE XMLNSC.NamespaceDecl NAME xmlns VALUE 'http...';


Like in the example here-above you probably should be using first child instead of lastchild...


_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
paustin_ours
PostPosted: Thu Feb 16, 2012 8:34 pm Post subject: Reply with quote

Yatiri

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

fjb_saper wrote:
paustin_ours wrote:
if i specify

DECLARE xmlns NAMESPACE 'http...." [ instead of leaving it blank '' like i did initially]

i get the below output

NS1:Envelope xmlns:NS1="http...."
NS1:Header

all the env: is gone. looks like this default namespace declaration is taking precedence and my other namespcace declarations are being ignored.

<env:Header>
<env:Body>
<test xmlns="http:....">


Ok so did you define env?
Code:
DECLARE env NAMESPACE 'http....';

SET OutputRoot.XMLNSC.env:Envelope.(XMLNSC.NamespaceDecl)xmlns:env='http...';


You need to define like that any namespace that you want to keep the specific name as prefix...

Have fun



I did do the

DECLARE env NAMESPACE 'http....';
SET OutputRoot...

the output comes out fine

but once i do the DECLARE xmlns NAMESPACE 'http....';

and use that to create

SET OuputRoot.XMLNSC.env:Envelope.env:Body.test.(XMLNSC.NamespaceDecl)xmlns= xmlns;

all the previously working fine tags now show NS1:Envelope etc., instead of env:Envelope

To me it looks like the default NAMESPACE decalration [ DECLARE xmlns..]
is maksing everything else.
Back to top
View user's profile Send private message Yahoo Messenger
Vitor
PostPosted: Fri Feb 17, 2012 5:32 am Post subject: Reply with quote

Grand High Poobah

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

kimbert wrote:
Vitor's code is a little verbose, but will work. The info center demonstrates the easier way to do it.


I have a resolved PMR on namespaces where the resolution included "add your suggestions for clarifying that part of the InfoCenter via the feedback button".

Which I did.

The code is the result of me getting in a tangle, which is no fault of the product.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
kimbert
PostPosted: Fri Feb 17, 2012 12:48 pm Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

paustin_ours: you're getting confused somewhere along the line, but I can't work out where. You certainly should not be declaring a namespace constant with name 'xmlns' - that simply doesn't make sense.

Please re-read the examples here: http://publib.boulder.ibm.com/infocenter/wmbhelp/v8r0m0/topic/com.ibm.etools.mft.doc/ac67194_.htm
I think they are quite clear and understandable, but I'm not the best judge. If you cannot work out what you need to do, then please
- post the entire XML snippet that you are trying to generate ( with the complete namespace URLS, not 'http://....' )
- post the exact ESQL that you are using
- post the XML output that you get, or else the full text of the error message.

I am more than willing to update the info center if it is not clear enough - suggestions are invited, as long as they are specific about what is not clear.
Back to top
View user's profile Send private message
Display posts from previous:
Post new topicReply to topic Goto page 1, 2  Next Page 1 of 2

MQSeries.net Forum IndexWebSphere Message Broker Supportxmlnsc attribute name xmlns
Jump to:



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


Theme by Dustin Baccetti
Powered by phpBB 2001, 2002 phpBB Group

Copyright MQSeries.net. All rights reserved.