{"id":1742,"date":"2011-03-22T11:09:24","date_gmt":"2011-03-22T05:39:24","guid":{"rendered":"http:\/\/JitendraZaa.com\/blog\/?p=1742"},"modified":"2011-03-22T11:09:24","modified_gmt":"2011-03-22T05:39:24","slug":"introduction-to-jaxp","status":"publish","type":"post","link":"https:\/\/www.jitendrazaa.com\/blog\/java\/introduction-to-jaxp\/","title":{"rendered":"Introduction to JAXP and Difference between JAXP and JAXB"},"content":{"rendered":"<p style=\"text-align: justify;\"><a title=\"Introduction to DOM\" href=\"https:\/\/jitendrazaa.com\/blog\/java\/dom-%E2%80%93-document-object-module\/\" target=\"_blank\">Previous article was about the introduction to DOM<\/a>. in this article i will focus on concept of handling XML data using DOM Parser in JAXP.<\/p>\n<p style=\"text-align: justify;\">The <strong>Java API for XML Processing (JAXP)<\/strong> is for processing XML data using applications written in the Java programming language. JAXP leverages the parser standards <strong>Simple API for XML Parsing (SAX) <\/strong>and <strong>Document Object Model (DOM) <\/strong>so that you can choose to parse your data as a stream of events or to build an object representation of it. JAXP also supports the <strong>Extensible Stylesheet Language Transformations (XSLT)<\/strong> standard, giving you control over the presentation of the data and enabling you to convert the data to other XML documents or to other formats, such as HTML.<\/p>\n<p style=\"text-align: justify;\"><strong>XML Processing in JAVA using DOM :<\/strong><br \/>\nThe Document Object Model (DOM) is a set of interfaces defined by the W3C DOM Working Group. It describes facilities for a programmatic representation of a parsed XML (or HTML) document.<\/p>\n<figure id=\"attachment_1743\" aria-describedby=\"caption-attachment-1743\" style=\"width: 508px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2011\/03\/XML-Processing-using-DOM-in-JAXP.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1743  \" title=\"XML Processing using DOM in JAXP\" alt=\"XML Processing using DOM in JAXP\" src=\"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2011\/03\/XML-Processing-using-DOM-in-JAXP.jpg?resize=508%2C213&#038;ssl=1\" width=\"508\" height=\"213\" \/><\/a><figcaption id=\"caption-attachment-1743\" class=\"wp-caption-text\">XML Processing using DOM in JAXP<\/figcaption><\/figure>\n<p><!--more-->Above diagram shows, how to handle the XML in case of DOM Parser in JAXP.<br \/>\nAs shown in above diagram, two classes <strong>DocumentBuilderFactory <\/strong>and <strong>DocumentBuilder <\/strong>are used to process the XML documents.<\/p>\n<p><strong>Extensible Stylesheet Language Transformations (XSLT):<\/strong><\/p>\n<figure id=\"attachment_1744\" aria-describedby=\"caption-attachment-1744\" style=\"width: 439px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2011\/03\/Extensible-Stylesheet-Language-Transformations.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1744 \" title=\"Extensible Stylesheet Language Transformations\" alt=\"Extensible Stylesheet Language Transformations\" src=\"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2011\/03\/Extensible-Stylesheet-Language-Transformations.jpg?resize=439%2C303&#038;ssl=1\" width=\"439\" height=\"303\" \/><\/a><figcaption id=\"caption-attachment-1744\" class=\"wp-caption-text\">Extensible Stylesheet Language Transformations<\/figcaption><\/figure>\n<p>A <strong>TransformerFactory <\/strong>object is instantiated and used to create a <strong>Transformer<\/strong>. The source object is the input to the transformation process. A source object can be created from a SAX reader, from a DOM, or from an input stream.<br \/>\nSimilarly, the result object is the result of the transformation process. That object can be a SAX event handler, a DOM, or an output stream.<br \/>\nWhen the transformer is created, it can be created from a set of transformation instructions, in which case the specified transformations are carried out. If it is created without any specific instructions, then the transformer object simply copies the source to the result.<\/p>\n<p style=\"text-align: justify;\">There is other XML API in Java, &#8220;<strong>JAXB<\/strong>&#8221; stands for the <strong>&#8220;JAVA Architexture for XML Binding (JAXB)&#8221;<\/strong>. It provides the capability of mapping Java classes to XML representations, and simplifies access to an XML document for a Java program. The first step in this process is to bind the XML Schema into a set of Java classes that represents the schema. JAXB provides two main features:<\/p>\n<ul>\n<li>The ability to marshal Java objects into XML<\/li>\n<li>The ability to unmarshal XML back into Java objects.<\/li>\n<\/ul>\n<p style=\"text-align: justify;\">JAXB is one of the APIs in the Java EE platform, and is part of the Java Web Services Development Pack (JWSDP). It is also one of the foundations for WSIT. JAXB is part of SE version 1.6.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction to JAXP (JAVA API for XML Processing), SAX (Simple API for XML Parsing),Extensible Style sheet language transformation (XSLT) <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"jz_research_post":"","_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[3],"tags":[329,128,129,227],"class_list":["post-1742","post","type-post","status-publish","format-standard","hentry","category-java","tag-java","tag-jaxb","tag-jaxp","tag-xml"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":1774,"url":"https:\/\/www.jitendrazaa.com\/blog\/java\/difference-between-sax-and-dom-parsers\/","url_meta":{"origin":1742,"position":0},"title":"Difference between SAX and DOM Parsers","author":"Jitendra","date":"March 22, 2011","format":false,"excerpt":"What is the difference between SAX And DOM Parsers","rel":"","context":"In &quot;JAVA&quot;","block_context":{"text":"JAVA","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/java\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1750,"url":"https:\/\/www.jitendrazaa.com\/blog\/java\/create-xml-file-using-jaxp-and-transformation-apis\/","url_meta":{"origin":1742,"position":1},"title":"Create XML File using DOM Parser of JAXP and Transformation APIs","author":"Jitendra","date":"March 22, 2011","format":false,"excerpt":"Example of Creating XML File using JAXP and Transformation APIs","rel":"","context":"In &quot;JAVA&quot;","block_context":{"text":"JAVA","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/java\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1753,"url":"https:\/\/www.jitendrazaa.com\/blog\/java\/traverse-xml-file-using-dom-parser-of-jaxp\/","url_meta":{"origin":1742,"position":2},"title":"Traverse XML file using DOM Parser of JAXP","author":"Jitendra","date":"March 22, 2011","format":false,"excerpt":"Example of Traverse XML file using DOM Parser of JAXP","rel":"","context":"In &quot;JAVA&quot;","block_context":{"text":"JAVA","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/java\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1756,"url":"https:\/\/www.jitendrazaa.com\/blog\/java\/searching-xml-file-using-dom-parser-of-jaxp\/","url_meta":{"origin":1742,"position":3},"title":"Searching XML File using DOM Parser of JAXP","author":"Jitendra","date":"March 22, 2011","format":false,"excerpt":"Example of Searching XML File using DOM Parser of JAXP","rel":"","context":"In &quot;JAVA&quot;","block_context":{"text":"JAVA","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/java\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1764,"url":"https:\/\/www.jitendrazaa.com\/blog\/java\/read-xml-file-using-sax-parser-in-java\/","url_meta":{"origin":1742,"position":4},"title":"Read XML File using SAX Parser in JAVA","author":"Jitendra","date":"March 22, 2011","format":false,"excerpt":"Example of Reading XML File using SAX Parser in JAVA","rel":"","context":"In &quot;JAVA&quot;","block_context":{"text":"JAVA","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/java\/"},"img":{"alt_text":"SAX Parser","src":"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2011\/03\/SAX-Parser.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":2120,"url":"https:\/\/www.jitendrazaa.com\/blog\/java\/validate-xml-schema-using-dom-parser-and-sax-parser-in-java-using-swing\/","url_meta":{"origin":1742,"position":5},"title":"Validate XML Schema Using DOM Parser and SAX Parser in JAVA Using Swing","author":"Jitendra","date":"May 13, 2011","format":false,"excerpt":"Validate XML Schema Using DOM Parser and SAX Parser in JAVA Using Swing","rel":"","context":"In &quot;JAVA&quot;","block_context":{"text":"JAVA","link":"https:\/\/www.jitendrazaa.com\/blog\/category\/java\/"},"img":{"alt_text":"Input Screen - XML Schema Validation in JAVA Using DOM and SAX Parser","src":"https:\/\/i0.wp.com\/jitendrazaa.com\/blog\/wp-content\/uploads\/2011\/05\/Input-Screen-XML-Schema-Validation-in-JAVA-Using-DOM-and-SAX-Parser.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/posts\/1742","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/comments?post=1742"}],"version-history":[{"count":0,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/posts\/1742\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/media?parent=1742"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/categories?post=1742"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jitendrazaa.com\/blog\/wp-json\/wp\/v2\/tags?post=1742"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}