Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between parsing and transformation?

I'm wondering what is the difference between data parsing and transformation.

For example, if I need to convert data from XML format to JSON format will it be a transformation or parsing?

like image 326
user3396478 Avatar asked Feb 19 '26 18:02

user3396478


2 Answers

Transformation is a mapping from one form to another.

  • An XSLT transformation maps from XML to JSON, HTML, (different) XML, etc.

Parsing is an analysis of a sequential form to identify structural parts.

  • An XML parser reads XML and identifies its elements, attributes, and other parts.

Data conversion is fundamentally a transformation. Note, though, that transformations often leverage structure identified during parsing of the input form to create the output form.

like image 74
kjhughes Avatar answered Feb 24 '26 06:02

kjhughes


Parsing technically is the process of establishing the logical structure of the textual input: for example establishing that <a b="3"/> represents an element named a containing an attribute named b whose value is 3.

Unfortunately the term seems to be increasingly misunderstood, and programmers without formal computer science training often misuse the term to mean almost any processing of the parsed data: we see questions on SO saying "I am writing a parser", when actually they are writing an application that consumes the output of a parser.

Converting XML to JSON is a three-stage process: parsing the XML, transforming the resulting data structure to a different data structure, and then serializing the transformed data structure into JSON syntax.

like image 23
Michael Kay Avatar answered Feb 24 '26 05:02

Michael Kay



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!