Showing posts with label Xml Technologies. Show all posts
Showing posts with label Xml Technologies. Show all posts

When to use Xml and when to use JSON

 

XML

JSON

You need message validation

You don't need Messages to be validated

XML transfer is slower then JSON since the file size is relatively compared to JSON.

JSON is a good if you want to transmit data faster from client to server, due to reduced file size

You need to transform the XML i.e. if  using XSLT

You're not transforming messages, or transforming their de serialization is simple

Your messages include a lot of marked-up text

Your messages are mostly data, not marked-up text

You need to interoperate with environments that don't support JSON

The messaging endpoints have good JSON tools

Used when objective is to carry or store data

Used when objective is to display the Data

When there is no concern for reduced file/transfer size.

When there is a requirement for reduced file/transfer size.

Processing is slower since XML has to be parsed with XML parser.

Processing is faster since JSON can be parsed by a standard JavaScript function.

 

Difference between XML and JSON

XML

JSON

XML is more verbose than JSON

JSON is less verbose than XML

XML is tree based

JSON’s data structure is a map

Xml was designed to carry or store data.

JSON was designed to carry and display data.

Xml is based on SGML

JSON is text based following Java Script Object Notation.

Xml supports namespace

JSON doesn’t support any namespace

Xml supports comments

JSON doesn’t supports comments.

Xml supports Start and End Tags

JSON doesn’t support End tags

Xml doesn’t support array

JSON supports array

XML has to be parsed with XML parser.

JSON can be parsed by a standard JavaScript function.

Parsing process -

Fetch an XML document

Use the XML DOM to loop through the document

Extract values and store in variables

Parsing process -

Fetch a JSON string

Parse the JSON string

 

Xml parsing is slower since DOM parsing is slower.

JSON Parsing is faster since its based on format of Javascript object.

Xml message validation is supported using XML schemas

JSON validation is supported using JSON Schema, but it is not comprehensive compared to XSD

Xml can be easily transformed using XSLT

No Transformation is available.

Difference between include and import elements in XML Schema - XSD with Example

As we all know that include and import elements in a xsd is used to reference schema components from another schema,
In this post I will explore the difference between them and when to use what with simple examples and how we can use the same in BizTalk Server.

Include element - include refers to declarations or definitions that are from same namespace or a no target namespace.
That is if the Schema being added also contains elements with same namespace then we can directly include it.
XSD Include means Importing types from another schema within the SAME namespace
When we are referring to the declarations or definitions from the same namespaces then we use Include element.

Import element - import refers to declarations or definitions that are from a different target namespace.
The import element is used to add multiple schema's with different target namespace to a document.
XSD Import means Importing types from another schema/namespace
When we are referring to the declarations or definitions from different namespaces then we use Import element.

XML Design Consideration – What Should be used XML Elements or Attributes - BizTalk Schema Design Consideration

The choice of Element or Attribute for a data depends on different factors like -

1) Attributes take up only about half the space that elements take up.
This is because an attribute called OrderNumber will have the word OrderNumber only once, whereas
Element will have both a start tag and an end tag, meaning that the word OrderNumber will appear twice, in the opening and closing brackets for the tags. 
Hence the file size is comparable more if elements are used.

2) Elements can occur multiple times, attributes cannot, that is an element cannot contain multiple attributes with same name.

3) Property promotion in BizTalk works only for elements and not for attributes.

4) The structure of the external system to be integrated.

Links -

XML Elements, Attributes, and Types (XML Designer)

How to get the root node name of an xml document /node name of any xml element using XPath name() function in Expression Shape BizTalk Server with Examples

Hi, this posts explains how to use XPath Expressions to get the Node Name of an XML Document.
The Xpath expression can be used inside the Expression shape of BizTalk server using the xpath function.

If the business process is tied to the XML then Root Node name can be used to identify the business process being executed in BizTalk Server.

We can get the Root Node name or name of any node using the name() function, by passing  XPath as input parameter

Syntax:
name(XPath Expression)

Example

Input XML
<OrderId>
<OrderRecord>
       <Place>ALT</Place>
       <Date>21-Aug-2011</Date>
</OrderRecord>
<OrderNo>123</OrderNo>
</OrderId>
i) name(/*) 
Result: OrderId

ii) name(/*/*)
Result: OrderRecord

iii) name(/*/*[2])
Result: OrderId