{"id":385,"date":"2019-01-24T04:01:21","date_gmt":"2019-01-24T04:01:21","guid":{"rendered":"http:\/\/www.yohz.com\/blogs\/?p=385"},"modified":"2019-01-24T04:56:48","modified_gmt":"2019-01-24T04:56:48","slug":"db-doc-6-and-xml-files","status":"publish","type":"post","link":"https:\/\/www.yohz.com\/blogs\/2019\/01\/24\/db-doc-6-and-xml-files\/","title":{"rendered":"DB Doc 6 and XML files"},"content":{"rendered":"<p>New in <a href=\"http:\/\/www.yohz.com\/dbdoc_details.htm\">DB Doc 6<\/a> is the option to export your PostgreSQL database schema in XML format.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-386\" src=\"http:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2019\/01\/dbdoc_xml01.png\" alt=\"\" width=\"648\" height=\"481\" srcset=\"https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2019\/01\/dbdoc_xml01.png 648w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2019\/01\/dbdoc_xml01-300x223.png 300w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2019\/01\/dbdoc_xml01-624x463.png 624w\" sizes=\"(max-width: 648px) 100vw, 648px\" \/><\/p>\n<p>We provide a script to generate the XML file, and also a sample XSL stylesheet to display the XML files in your browser.\u00a0 The provided XML structure is very basic, and if you need to modify the XML structure, it&#8217;s very simple to do.<\/p>\n<p>For example, let&#8217;s take a look at the XML file that&#8217;s generated for a view.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-389\" src=\"http:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2019\/01\/dbdoc_xml03.png\" alt=\"\" width=\"921\" height=\"304\" srcset=\"https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2019\/01\/dbdoc_xml03.png 921w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2019\/01\/dbdoc_xml03-300x99.png 300w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2019\/01\/dbdoc_xml03-768x253.png 768w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2019\/01\/dbdoc_xml03-624x206.png 624w\" sizes=\"(max-width: 921px) 100vw, 921px\" \/><\/p>\n<p>This is the script that generates the XML file for the properties section of the view.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-390\" src=\"http:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2019\/01\/dbdoc_xml04.png\" alt=\"\" width=\"1087\" height=\"277\" srcset=\"https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2019\/01\/dbdoc_xml04.png 1087w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2019\/01\/dbdoc_xml04-300x76.png 300w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2019\/01\/dbdoc_xml04-768x196.png 768w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2019\/01\/dbdoc_xml04-1024x261.png 1024w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2019\/01\/dbdoc_xml04-624x159.png 624w\" sizes=\"(max-width: 1087px) 100vw, 1087px\" \/><\/p>\n<p>Now let&#8217;s say you have an application that will process the XML file, and needs the &#8216;OID&#8217; and &#8216;owner&#8217; properties to be easily accessed.\u00a0 The provided script generates these nodes as part of the &#8216;properties&#8217; collection, which is great for a stylesheet, but not so easily accessed by an application that needs to read those values.<\/p>\n<p>So we need to be able to generate 2 &#8216;types&#8217; of XML files &#8211; one to be easily displayed, and one to be easily read.\u00a0 We also don&#8217;t want to have to maintain 2 different scripts.<\/p>\n<p>So first, let&#8217;s add the code to generate the &#8216;OID&#8217; and &#8216;owner&#8217; values in their own nodes.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-391\" src=\"http:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2019\/01\/dbdoc_xml05.png\" alt=\"\" width=\"1026\" height=\"295\" srcset=\"https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2019\/01\/dbdoc_xml05.png 1026w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2019\/01\/dbdoc_xml05-300x86.png 300w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2019\/01\/dbdoc_xml05-768x221.png 768w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2019\/01\/dbdoc_xml05-1024x294.png 1024w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2019\/01\/dbdoc_xml05-624x179.png 624w\" sizes=\"(max-width: 1026px) 100vw, 1026px\" \/><\/p>\n<p>At this point, our XML file will contain 2 nodes with the &#8216;OID&#8217; and &#8216;owner&#8217; values, like this.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-392\" src=\"http:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2019\/01\/dbdoc_xml06.png\" alt=\"\" width=\"923\" height=\"326\" srcset=\"https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2019\/01\/dbdoc_xml06.png 923w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2019\/01\/dbdoc_xml06-300x106.png 300w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2019\/01\/dbdoc_xml06-768x271.png 768w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2019\/01\/dbdoc_xml06-624x220.png 624w\" sizes=\"(max-width: 923px) 100vw, 923px\" \/><\/p>\n<p>We could leave it as is &#8211; our application will read the values it requires from the top-level node, while our stylesheet will read the values from the &#8216;properties&#8217; collection and ignore the top-level node.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-396\" src=\"http:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2019\/01\/dbdoc_xml10.png\" alt=\"\" width=\"1047\" height=\"361\" srcset=\"https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2019\/01\/dbdoc_xml10.png 1047w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2019\/01\/dbdoc_xml10-300x103.png 300w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2019\/01\/dbdoc_xml10-768x265.png 768w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2019\/01\/dbdoc_xml10-1024x353.png 1024w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2019\/01\/dbdoc_xml10-624x215.png 624w\" sizes=\"(max-width: 1047px) 100vw, 1047px\" \/><\/p>\n<p>Or we could make the script leave out the redundant nodes depending on which version of the XML file we need.\u00a0 We can do this using the DB Doc script user-defined values.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-393\" src=\"http:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2019\/01\/dbdoc_xml07.png\" alt=\"\" width=\"624\" height=\"472\" srcset=\"https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2019\/01\/dbdoc_xml07.png 624w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2019\/01\/dbdoc_xml07-300x227.png 300w\" sizes=\"(max-width: 624px) 100vw, 624px\" \/><\/p>\n<p>Let&#8217;s say the default output is to have the &#8216;OID&#8217; and &#8216;owner&#8217; values as part of the &#8216;properties&#8217; collection.\u00a0 When we want the other output, we will define a value named &#8216;PARSER&#8217; as the first user-defined value.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-394\" src=\"http:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2019\/01\/dbdoc_xml08.png\" alt=\"\" width=\"645\" height=\"471\" srcset=\"https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2019\/01\/dbdoc_xml08.png 645w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2019\/01\/dbdoc_xml08-300x219.png 300w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2019\/01\/dbdoc_xml08-624x456.png 624w\" sizes=\"(max-width: 645px) 100vw, 645px\" \/><\/p>\n<p>In our script, we simply look for this user-defined value to generate the correct output.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-395\" src=\"http:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2019\/01\/dbdoc_xml09.png\" alt=\"\" width=\"1100\" height=\"347\" srcset=\"https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2019\/01\/dbdoc_xml09.png 1100w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2019\/01\/dbdoc_xml09-300x95.png 300w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2019\/01\/dbdoc_xml09-768x242.png 768w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2019\/01\/dbdoc_xml09-1024x323.png 1024w, https:\/\/www.yohz.com\/blogs\/wp-content\/uploads\/2019\/01\/dbdoc_xml09-624x197.png 624w\" sizes=\"(max-width: 1100px) 100vw, 1100px\" \/><\/p>\n<p>Now every time we want to generate the XML file for our application to use, just enter the value PARSER as the first user-defined value, and DB Doc will generate the XML file accordingly.\u00a0 Thus, we only need to maintain a single script file.<\/p>\n<p>More details about DB Doc can be found <a href=\"http:\/\/www.yohz.com\/dbdoc_details.htm\">here<\/a>, and you can download a free 14-day trial using this <a href=\"http:\/\/www.yohz.com\/downloads\/dbdoc\/DBDocSetup.zip\">link<\/a>.<\/p>\n<div class=\"fcbkbttn_buttons_block\" id=\"fcbkbttn_left\"><div class=\"fcbkbttn_like \"><fb:like href=\"https:\/\/www.yohz.com\/blogs\/2019\/01\/24\/db-doc-6-and-xml-files\/\" action=\"like\" colorscheme=\"light\" layout=\"button\"  size=\"small\"><\/fb:like><\/div><div class=\"fb-share-button  \" data-href=\"https:\/\/www.yohz.com\/blogs\/2019\/01\/24\/db-doc-6-and-xml-files\/\" data-type=\"button\" data-size=\"small\"><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>New in DB Doc 6 is the option to export your PostgreSQL database schema in XML format. We provide a script to generate the XML file, and also a sample XSL stylesheet to display the XML files in your browser.\u00a0 The provided XML structure is very basic, and if you need to modify the XML [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[6],"tags":[50,3,49],"_links":{"self":[{"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/posts\/385"}],"collection":[{"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/comments?post=385"}],"version-history":[{"count":3,"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/posts\/385\/revisions"}],"predecessor-version":[{"id":400,"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/posts\/385\/revisions\/400"}],"wp:attachment":[{"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/media?parent=385"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/categories?post=385"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yohz.com\/blogs\/wp-json\/wp\/v2\/tags?post=385"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}