locked
Use ANY field or name value pair in the schema to make generic RRS feed

  • Question

  • Hi,

    We are in process of creating generic schema  so that in future if we need to to pass or add extra field then it can be done easily.In order to make to more generic and loosely we are planning to use one of the option mentioned below:

    1) Any field

    2) Name-value pair

    Both of these options provides the flexibility to accept additional fields if needed to pass in the message , so we are confused which one to use in our schema any filed or name-value pair to make the schema more generic and flexible 

    Need your suggestion on these point .

    THanks



    Manish

    Wednesday, September 23, 2015 2:07 PM

Answers

  • Hi Manish,

    I think it depends upon your use case to be honest.

    If you are only interested in passing around a payload from place to place and you have an ability to make routing or business decisions on data within your current structure then <any> gives you that flexibility.

    As soon as there is any requirement to make decisions based on content you're introducing potentially a lot of other code/xpath/etc. in to the mix to get the data from what is untyped information. This will increase development and test burden, and introduce potential operational risk.

    Key/value pair works well if the number of elements is relatively low and there are no (or at least limited) relationships between them. But again, once things get beyond a certain point you can start getting complex very quickly. 

    Otherwise introducing versioning strategies around your schemas, using multi-part messages in Orchestrations and other techniques can all help isolate issues with change.

    Cheers,

    Martin

    Thursday, September 24, 2015 12:12 AM

All replies

  • No aware of the requirement completely but for ur question, I would prefer Name Value pair. It gives the required flexibility as well as a defined structure over which u can have ur rules , business logic etc . With Any field it would mean just any structure making further rules logic implementation complex probably.

    but it would really depend on ur business requirement as to which would suit the best


    Regards &lt;br/&gt; When you see answers and helpful posts,&lt;br/&gt; please click Vote As Helpful, Propose As Answer, and/or Mark As Answer

    Wednesday, September 23, 2015 2:32 PM
    Answerer
  • Hi Manish ,

     XSD <any> element is good while you design any generic schema or a schema to contain something unexpected/undefined or set of defined XML or elements.

    The <any> element provides a way to keep/contain XML element which is not defined in the schema. For more details and example, Please read here :

    Refer Nausad good post https://alamnaushad.wordpress.com/2012/02/25/biztalk-schema-to-use-any-element/

    Thanks

    Abhishek


    Wednesday, September 23, 2015 2:36 PM
  • Hi Manish,

    As correctly highlighted by Pi_xel_xar, I would also prefer Name-Value pair if you have straight forward requirment of handling extra fields that can be added later. This option will give you much more flexibility and easy to manage while doing the mapping to destination schemas. For more details on Name-Value pair you can check a great blog by Sandro Pereira:

    How to Map Name Value Pair to a Hierarchical Schema

    But if your schema may be added with complex Elements in future, then <any> element will be more appropriate to handle the scenario. obviously you have write XSLT or Scripting function to map the element to the destination if your Destination schema is more structured.

    Please indicate "Mark as Answer" or "Mark as Helpful" if this post has answered the question

    Rahul

    Wednesday, September 23, 2015 3:49 PM
  • Between the two, I would choose name/value pairs.

    It's a fairly common pattern for supporting 'custom' or 'extra' fields not directly supported by the app at one end of the conversation.

    If you expect to support complex structures, like sub-Xml documents, then <Any> is you best option vs encoded Xml strings.

    Wednesday, September 23, 2015 3:56 PM
    Moderator
  • Key/value pair is most recomended for custom fields.

    JB

    Wednesday, September 23, 2015 10:59 PM
  • Hi Manish,

    I think it depends upon your use case to be honest.

    If you are only interested in passing around a payload from place to place and you have an ability to make routing or business decisions on data within your current structure then <any> gives you that flexibility.

    As soon as there is any requirement to make decisions based on content you're introducing potentially a lot of other code/xpath/etc. in to the mix to get the data from what is untyped information. This will increase development and test burden, and introduce potential operational risk.

    Key/value pair works well if the number of elements is relatively low and there are no (or at least limited) relationships between them. But again, once things get beyond a certain point you can start getting complex very quickly. 

    Otherwise introducing versioning strategies around your schemas, using multi-part messages in Orchestrations and other techniques can all help isolate issues with change.

    Cheers,

    Martin

    Thursday, September 24, 2015 12:12 AM
  • If you use <any> element, it push you to use xpath when you process a message. In my experience it is helpful when you deal with such crazy complex schemas from OAGIS or from EDI, for example. (Oh boy, using these schemas for messaging should be prohibited.) This approach could eliminate a need in XML Schema at all. It is a way to use "untyped" messages (XmlDocument type). It works fine if you need a small number of elements from a message. Validating of such complex schemas makes no sense in case you deal across the boundaries of organization,  because it is so hard to create messages conform every element of schema. Mapping of such schemas with Xslt also makes little sense. XPath could be the best option. 

    Leonid Ganeline [BizTalk MVP]

    Thursday, September 24, 2015 3:19 AM
    Moderator
  • Hi All,

    Thank you all for the input. Yea i didnt give the complete requirement ,my mistake.

    In our projects we hardly deal with orchestration so most of the integrations are involved with messaging level scenario where map, custom pipeline and some wcf extensions are used .


    Manish

    Thursday, September 24, 2015 7:17 AM
  • Hey Manish,

    I don't think that changes things much, if the data is only payload and will remain payload then <any> can give you that flexibility.

    Mapping something that is untyped is going to involve potentially a lot of custom XSLT.

    Key/value pairs will get complex very quickly I suspect and again you're left with lots of custom XSLT.

    Cheers,

    Martin

    Thursday, September 24, 2015 7:40 AM
  • Hi Martin,

    Thanks for your suggestion.

    Now you confused me J. We are redesigning our schema where we are planning to split into 2 parts ,

    1. Header: which contains set of fixed fields
    2. Body/Detail : which will contains customer specific data .This section also we have some fixed fields (few) and then remaining will be dynamic. So to make it dynamic we are thinking what best to you <ANY> or Name-value pair (as most of them suggested).

    Note: Name-value pair will not go more than 20.

    Regards,

    Manish kumar


    Manish

    Thursday, September 24, 2015 8:22 AM