Author |
Message
|
venusboy |
Posted: Mon Nov 20, 2006 5:48 pm Post subject: Namespace Defaulting - MRMs |
|
|
Acolyte
Joined: 11 Jun 2002 Posts: 51
|
I have an XML Schema that I have modelled as an MRM, primary for validation purposes. The schema uses namespaces.
WMB decides to add namespace prefixes to the outgoing message, I need to default the namespace so that the prefixes do not appear (to reduce the size of the message).
Please note, I understand there are multiple posts on this subject, but I do not wish to remove the prefixes, just set a default namespace.
E.g. a simple example would be:
I need to output:
<book xmlns='urn:loc.gov:books'
<title>Cheaper by the Dozen</title>
</book>
My current output is:
<bookns:book xmlns:bookns='urn:loc.gov:books'
<bookns:title>Cheaper by the Dozen</bookns:title>
</bookns:book>
So I assume that I only need to perform something like:
OutputRoot.MRM.xmlns = 'urn:oc.gov:books'
But as am using MRMs then this attribute is not defined (or the namespace of this attribute is not defined). I have defined the default namespace within the MRM.
This is such an obvious thing to do need to do and would expect this as the default behaviour but am at a loss.
Thanks in advance. |
|
Back to top |
|
 |
elvis_gn |
Posted: Tue Nov 21, 2006 12:29 am Post subject: |
|
|
 Padawan
Joined: 08 Oct 2004 Posts: 1905 Location: Dubai
|
Hi venusboy,
venusboy wrote: |
Please note, I understand there are multiple posts on this subject, but I do not wish to remove the prefixes, just set a default namespace. |
I'm hoping u meant that u dont need the prefixes but the default namespace to apply.
For this
Quote: |
<book xmlns='urn:loc.gov:books'
<title>Cheaper by the Dozen</title>
</book> |
Try this (Untested code)
Code: |
DECLARE ns NAMESPACE "urn:loc.gov:books";
CALL CopyMessageHeaders();
CREATE LASTCHILD OF OutputRoot DOMAIN 'XMLNSC' NAME 'XMLNSC';
CREATE FIELD OutputRoot.XMLNSC.ns:Book;
SET OutputRoot.XMLNSC.ns:Book.(XML.NamespaceDecl) = 'urn:loc.gov:books';
SET OutputRoot.XMLNSC.ns:Book.ns:title = 'Cheaper by the Dozen'; |
Regards. |
|
Back to top |
|
 |
kimbert |
Posted: Tue Nov 21, 2006 1:26 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Hi venusboy,
You can set namespace prefixes for the MRM XML parser using a table in the XML message set properties. I'm not sure whether you are allowed to specify an empty prefix, though.
If you can't do it that way, you could switch to XMLNSC for output ( as elvis_gn suggests) - assuming that you do not require validation of the output message. |
|
Back to top |
|
 |
venusboy |
Posted: Tue Nov 21, 2006 2:31 am Post subject: |
|
|
Acolyte
Joined: 11 Jun 2002 Posts: 51
|
Kimbert, Elvis;
Thanks guys for your posts.
Kimbert, yes I need to validate the XML message, the actual message is a full soap envelope with about 8 namespaces thus having the prefixes really does increase the size.
The namespace mappings do not allow NULL. If they are not defined then the NS1, NS2 prefixes occur. |
|
Back to top |
|
 |
kimbert |
Posted: Tue Nov 21, 2006 4:09 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
So you need validation, but the only parser which can validate cannot output default namespaces. Do you really need to validate the output message. Would it be OK to validate the input message, and output using XMLNSC ( without validation )?
If you really require validation of the output message, the only other option is
- use a Validate node to validate the message tree while you're in the MRM domain
- Construct the output message tree under OutputRoot.XMLNSC
- Add namespace decls for the default namespace |
|
Back to top |
|
 |
venusboy |
Posted: Tue Nov 21, 2006 4:25 am Post subject: |
|
|
Acolyte
Joined: 11 Jun 2002 Posts: 51
|
Kimbert,
Thanks for your reply. Yes I really do need to validate the outgoing message if not I am breaking a contract between services and the system I am connecting to is external.
I suppose the question is performance, I don't wish to increase each message by a 20%, but the alternatives that you have sugguested would (I suppose) result in more CPU activity.
I just thought it was a very simple thing to want to do and it was something I have missed in the documention. |
|
Back to top |
|
 |
fazz |
Posted: Tue Nov 21, 2006 6:16 am Post subject: |
|
|
 Centurion
Joined: 20 Feb 2004 Posts: 144 Location: England
|
Not really a solution more of a compromise........but how about setting the prefixes in the message set file to be only one character long..? |
|
Back to top |
|
 |
|