Answered by:
Schema with multiple root elements

Question
-
Hi,
I am a bit new with BizTalk and have a problem at the moment.
From our customer we have received an .XSD which i imported in BizTalk as a schema. The schema has about 20 root nodes who arent nested in a real root node. So it was a bit of a problem creating a distinguished property but with a bit of tweaking i had it working.
So now the real problem, i created an orchestration in which the .xml file comes in which has an attribute number thats unique. If that number is 1 it has to go to folder 1 and if the number is 2 it has to go to folder 2. But when i create a new message in the orchestration and i want to select the schema but i dont see the schema file but instead i see all the root nodes of the xsd file.
How can i fix this problem so that i can use the whole schema in the orchestration instead of a root element.
Greetings,
RonaldMonday, March 15, 2010 9:55 AM
Answers
-
Hi,
Thanks for the information.
I did a quick review of the schema. In my opinion you only need the data element as the root for your messages. The only 'root' nodes seem to be type definitions used in the 'data' element or one of its children. One thing you can do is set the 'Root Reference' in the BizTalk schema editor to 'data'. In this way BizTalk knows the root node for the schema. In the orchestration BizTalk will only show a single message type for the schema.
HTH,
Randal van Splunteren - MVP, MCTS BizTalk Server
http://biztalkmessages.vansplunteren.net
Please mark as answered if this answers your question.
Check out the PowerShell provider for BizTalk: http://psbiztalk.codeplex.com- Marked as answer by Leonid GanelineModerator Thursday, March 18, 2010 5:07 PM
Monday, March 15, 2010 10:48 AMModerator
All replies
-
Hi Ronald,
This post can help: http://blog.eliasen.dk/2006/09/07/MultipleRootEntriesInSchemaLookUglyInSchemaEditor.aspx.
Regards,Steef-Jan Wiggers
MCTS BizTalk Server
http://soa-thoughts.blogspot.com/
If this answers your question please mark it accordingly
BizTalk- Proposed as answer by Leonid GanelineModerator Thursday, March 18, 2010 5:03 PM
Monday, March 15, 2010 10:04 AMModerator -
Hi,
You can't do that, a Xml message always has a single root. If you need information from multiple roots you will have to create a message for each root node inside the orchestration.
I must say I'm also a bit curios what your incoming xml looks like. Can you post a sample message of the incoming xml? From your story it looks like your receving a message in your orchestration that has multiple roots. Which is a little strange. Also please post the schema and the configuration of your receive port (what pipeline are you using).
Thanks
HTH,
Randal van Splunteren - MVP, MCTS BizTalk Server
http://biztalkmessages.vansplunteren.net
Please mark as answered if this answers your question.
Check out the PowerShell provider for BizTalk: http://psbiztalk.codeplex.com- Proposed as answer by Leonid GanelineModerator Thursday, March 18, 2010 5:03 PM
Monday, March 15, 2010 10:08 AMModerator -
When you have a schema with multiple root nodes you end up with multiple message types declared in BizTalk, one for every root node.
When you create a message you need to specify exactly which message type you are going to use.
You can create a generic orchestration that uses a message type of System.Xml.XmlDocument and then use the xpath function to extract your attribute.
e.g. stringAttributeValue = xpath(GenericMessage, string(/*/@attributename));- Proposed as answer by Leonid GanelineModerator Thursday, March 18, 2010 5:03 PM
Monday, March 15, 2010 10:11 AMAnswerer -
Ok, the .XSD and .XML are located at http://www.minihouse.eu/schemas/ under ncts_depature_v430.xsd its too big to post it here.
Its a format that is used by the customs.
When i was studying the .xsd and .xml it seems that the .xsd is very large compared to the .xml. It seems that there are lots of options in the .xsd which influence the outcome of the .xml file.
Its a bit of a dissapointment cause i dont have to do anything with the .xml file, its just that the file has to go to folder 1 or folder 2. The key for that decisson is the attribute: externalReference
Greetings,
RonaldMonday, March 15, 2010 10:34 AM -
Hi,
Thanks for the information.
I did a quick review of the schema. In my opinion you only need the data element as the root for your messages. The only 'root' nodes seem to be type definitions used in the 'data' element or one of its children. One thing you can do is set the 'Root Reference' in the BizTalk schema editor to 'data'. In this way BizTalk knows the root node for the schema. In the orchestration BizTalk will only show a single message type for the schema.
HTH,
Randal van Splunteren - MVP, MCTS BizTalk Server
http://biztalkmessages.vansplunteren.net
Please mark as answered if this answers your question.
Check out the PowerShell provider for BizTalk: http://psbiztalk.codeplex.com- Marked as answer by Leonid GanelineModerator Thursday, March 18, 2010 5:07 PM
Monday, March 15, 2010 10:48 AMModerator -
Hi,
After you set in the properties of the schema what the rootnode is you will still see the other elements in BizTalk. When you don't want to see them separatly you have to set the "displayroot_reference" attribute by hand. To do this you will have to open the .xsd schema in a XML editor (Open With option) and set the displayroot_reference attribute to "data"
See example:
<xsd:annotation>
<xsd:appinfo>
<schemaInfo root_reference="data" xmlns="http://schemas.microsoft.com/BizTalk/2003" displayroot_reference="data" />
</xsd:appinfo>
</xsd:annotation>
greetings,
Tomasso GroenendijkMonday, March 15, 2010 11:13 AM -
Hi,
I would like to add that the property 'displayroot_reference' only influences the way the schema is displayed in the Biztalk schema editor. To be able to easily pick the schema in the orchestration designer setting the root reference property is sufficient.
HTH,
Randal van Splunteren - MVP, MCTS BizTalk Server
http://biztalkmessages.vansplunteren.net
Please mark as answered if this answers your question.
Check out the PowerShell provider for BizTalk: http://psbiztalk.codeplex.comMonday, March 15, 2010 11:20 AMModerator -
The solution that Randal gave worked indeed for the schema's in the orchestration. I can now select the complete schema instead of all different root nodes.
I also set the "displayroot_reference" in the .xsd, but i still see the other root nodes in the schema.
The problem i have now is that i cant set promoted properties or distinguished property's.
When i want to promote data. Declaration.reference i get the error: This node can occur potentially multiple times in the instance document. Only nodes which are guaranteed to be unique can be promoted.
So then i tried to promote the other field in Declaration.reference and that goes without a problem. But when i now enter a expression in the orchestration it doesnt seems to recognize(syntax expression) the promoted field. So the orchestration selected the complete schema but has only the elements of the data node. This isnt a problem, but when i cant promote the reference field in data i cant create a expression.Monday, March 15, 2010 12:16 PM -
Hi,
I would like to add that the 'displayroot_reference' mentioned above only affects the way the schema is shown inside the BizTalk schema editor. This will not affect the orchestration designer. As I mentioned before 'root_reference' is sufficient for the type picker the orchestration designer.
HTH,
Randal van Splunteren - MVP, MCTS BizTalk Server
http://biztalkmessages.vansplunteren.net
Please mark as answered if this answers your question.
Check out the PowerShell provider for BizTalk: http://psbiztalk.codeplex.comMonday, March 15, 2010 12:18 PMModerator -
Hi,
This is default BizTalk behaviour; you can only promote or distuinguish fields that occur max. one time in the message. Otherwise I would lead to two identical context properties with different values. This is not allowed.
There are a couple of things you can do:
- Change the max. occurs in the schema to 1. Make sure the xml instances will only contain one node before you do this.
- Promote or write a property in code using a custom pipeline component
- Use Xpath statement in your orchestration's expression shap to get to the node value. Instead of using the promoted property or distuinguished syntax you can use xpath(message, '//.....') to get the value you need.
HTH,
Randal van Splunteren - MVP, MCTS BizTalk Server
http://biztalkmessages.vansplunteren.net
Please mark as answered if this answers your question.
Check out the PowerShell provider for BizTalk: http://psbiztalk.codeplex.comMonday, March 15, 2010 12:26 PMModerator -
Hi,
It worked when i changed the max.occurs to 1. cause in these files we have only one reference.
Now i have a last problem: the reference string consist of a string like "1 096604/40/BN000418"
So to test the whole application i've changed the number to "1", but now that the application works i want to change the expression. But the only part of the string i need is the first character, in the sample above the "1" which is the most left character in the string.
The current expression is: msgNCTS.Declaration.reference == "1"
How do i create this new expression?Wednesday, March 17, 2010 3:20 PM -
Hi,
You can just use string manipulation features provided by the .NET framework.
First declare a helper variable.
Second add an expression:
referenceString = msgNCTS.Declaration.reference;
Finally in the decide shape use somthing like this:
referenceString.Substring(0,1) == "1"
HTH,
Randal van Splunteren - MVP, MCTS BizTalk Server
http://biztalkmessages.vansplunteren.net
Please mark as answered if this answers your question.
Check out the PowerShell provider for BizTalk: http://psbiztalk.codeplex.comThursday, March 18, 2010 9:27 AMModerator -
Hi,
Unfortunately the expression isnt working.
But this is more of a C# problem i think. I will change the state of this topic to answered cause the schema and orchestration are working correct. Thanks for the help.Friday, March 19, 2010 8:34 AM -
It is sad this answer didn't get selected. Randal has great inputs and helped the OP far and beyond the original problem, which is fantastic, but Greg's answer was accurate and to the point. Would be great if a moderator could mark this answer as an answer on this thread.
My Technet Articles
If you like this or another reply, vote it up!
If you think this or another reply answers the original question, mark it or propose it as an answer.
Mauricio Feijo
www.mauriciofeijo.comWednesday, May 17, 2017 12:18 PM