|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Auto generation of default value in xsd using XMLNSC |
« View previous topic :: View next topic » |
Author |
Message
|
angka |
Posted: Thu Nov 17, 2011 2:46 am Post subject: Auto generation of default value in xsd using XMLNSC |
|
|
Chevalier
Joined: 20 Sep 2005 Posts: 406
|
Hi,
Is there a way to auto generate the element with default value of the xsd if the xml does not have the element using XMLNSC with validation on?
Below is what I did:
I created a xsd with 5 elements with minoccur=1 and default value set. i import as mxsd. I have a simple flow with input, compute, resetcontentdescriptor and output node.
In the compute node:
I set outputroot.xmlnsc.ns1:root:ns1:ele1 = '5';
In the resetcontentdescriptor node:
I set the domain as 'xmlnsc', the message set and turn on validation as 'content and value'
I run the flow and get erorr 'the content of element ns1:root is not complete'
I thought with validation on, broker will validate against the xsd and create those elements with default value from the xsd if it is not in the outputroot tree?
Below is extract from message model redbook:
Local element logical properties
XMLNSC domain
When parsing with validation enabled, default values are applied to
missing attributes and empty elements as required by the XML Schema
1.0 specification. When writing, elements or attributes that are missing
from the message tree are not automatically added to the output XML
bit stream, even if they have default values. If missing elements or
attributes are required, the message tree can be serialized and then
re-parsed with validation enabled. |
|
Back to top |
|
 |
saurabh867 |
Posted: Thu Nov 17, 2011 3:24 am Post subject: |
|
|
Voyager
Joined: 13 Jun 2010 Posts: 78
|
Hi,
Did you create the empty elements? As per the documentation, empty elements should be created then it would populate the default values but I think you are not creating the elements itself which may cause schema failure as the elements may be mandatory.
Quote: |
When parsing with validation enabled, default values are applied to
missing attributes and empty elements as required by the XML Schema
1.0 specification. |
Regards,
Saurabh |
|
Back to top |
|
 |
angka |
Posted: Thu Nov 17, 2011 3:53 am Post subject: |
|
|
Chevalier
Joined: 20 Sep 2005 Posts: 406
|
Hi,
Ya, I did not create an empty element but the last sentence state this:
If missing elements or attributes are required, the message tree can be serialized and then re-parsed with validation enabled.
Thanks |
|
Back to top |
|
 |
kimbert |
Posted: Thu Nov 17, 2011 5:24 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
I think the words in the info center could be better. They should say:
Quote: |
If required attributes with default values are missing from the message tree then they can be added automatically by writing the message tree and re-parsing with validation enabled.
If required simple elements are present in the message tree with no value or with the empty string as their value then the default value can be automatically assigned to these elements writing the message tree and re-parsing with validation enabled. |
Quite a lot harder to read, but more accurate. |
|
Back to top |
|
 |
angka |
Posted: Thu Nov 17, 2011 6:04 pm Post subject: |
|
|
Chevalier
Joined: 20 Sep 2005 Posts: 406
|
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|