none
Setting xml node property at runtime

    General discussion

  • Hi,

    I need to set some properties of my xml node at runtime. Can I do it?

    Say my node is Value node and it has different properties like 'Base Data Type, Content Type, Data Structure Type, Data Type'.

    So at runtime, for e.g. I need to set Base Data Type to 'String' or say Data Structure Type to 'String'. How can I do it?


    Ayaz Shaikh
    Tuesday, December 14, 2010 1:24 PM

All replies

  • Hi

    Looks like you are referring to attributes of an XML Node.

    If so , you can use xpath to set the values at runtime.

    Also, if you look at the schema source in BizTalk,all the properties of an element are considered as attributes.

    HTH

    Regards

    Sullu.


    http://biztalkguide.blogspot.com/ Please mark as answer if this solved the issue.Thanks
    Tuesday, December 14, 2010 2:00 PM
  • Are you talking about on the schema?  These properties that you mention are schema properties, not instance properties. What are you trying to accomplish?

    Shawn


    Shawn Morgan Blue Arch Solutions, Inc. shawn.morgan@bluearchsolutions.com
    Tuesday, December 14, 2010 11:14 PM
  • Hi Ayaz,

    can you provide full scenario, I am not sure if we can change the datatype for the message instance.

    -D

    Wednesday, December 15, 2010 3:34 AM
  • Hi Everyone,

    Thanks for your reply.

    Actually I have one node "Value" and its type is "xs:anyType". Now I want to set the type to 'String' if value is text and to 'DateTime' if value is date. To achieve this I need to set the type of the Value node.


    Ayaz Shaikh
    Wednesday, December 15, 2010 4:34 AM
  • Hi,

    An option is to create a custom .Net object in a C# project to set the value and call the object in an orchestration. You can also call a custom .Net object in a mapping,.

    greetings,

     

    Tomasso Groenendijk

     

    Wednesday, December 15, 2010 6:19 PM
  • Hi Everyone,

    Thanks for your reply.

    Actually I have one node "Value" and its type is "xs:anyType". Now I want to set the type to 'String' if value is text and to 'DateTime' if value is date. To achieve this I need to set the type of the Value node.


    Ayaz Shaikh


    I still don't understand.

    You work with node types in schema. Is this attribute,  "xs:anyType", in schema?

    It means, the Xml document based on this schema can use as this node almost everything, String, DateTime... Whatever you want.

    BTW. All data in Xml just text and nothing more. Just text! It is up to consumer, how to deserialize it. Consumer uses the schema (it is the definition of this document) to deserialize nodes to correspondent type (type defined in schema).

    If this node is just one element with primitive type like String of DateTime, you can use many methods to convert this text (in Xml document it always text!) to desirable format. For example: System.Convert.ToInt32("334535").


    Leonid Ganeline [BizTalk MVP] Biztalkien blog
    Thursday, December 16, 2010 4:06 AM
  • Hi Ayaz ,

    Can you please clarify why do you really want to specify the  datatype at Runtime as this is defined while creating the Schema at the start and you can set the dataype to either String and any type you want .Request you to perform the validation if any on the value instead of changing tha datatype .Is there any specific requirement that you want to accomplish .

    Thanks

    Harpreet Singh sandhu


    Harpreet Singh Sandhu
    Friday, December 17, 2010 7:39 AM
  • Hi,

    I am using MDS Service and in the request if I don't set type of the Value node to String it gives me 'DeserializationFailed' error and if I set it to 'String', it works perfectly well. This is the reason why I need to set the type explicitly.

    So please let me know how can I set the type?


    Ayaz Shaikh
    Friday, December 17, 2010 11:01 AM
  • Ayaz,

    I think people are confused because the type is defined on the schema, and you are talking about data in an instance document.  Who is giving you a DeserializationFailed error?  What is happening when this error occurs? 

    Shawn


    Shawn Morgan Blue Arch Solutions, Inc. shawn.morgan@bluearchsolutions.com
    Friday, December 17, 2010 8:34 PM
  • Hi Shawn Morgan,

    Actually data in instance document is causing the problem as type is not specified explicitly in the Value node and these data gives me DeserializationFailed error. When this error occured it gives me SOAPFault error in return.


    Ayaz Shaikh
    Tuesday, December 21, 2010 1:34 PM