Transforming An Old Xml Essay
<h3 class="heading-h6"><a name="THLToolboxhomegtWebDevelopmentgtTransforminganOldXMLEssay" class="anchorpoint"></a><a href="/tools/wiki/home.html">THL Toolbox</a> > <a href="/tools/wiki/Web%20Development.html">Web Development</a> > Transforming an Old XML Essay</h3><p class="paragraph">
</p><h3 class="heading-h1"><a name="TransforminganOldXMLPage" class="anchorpoint"></a>Transforming an Old XML Page</h3><p class="paragraph"><strong class="bold">Contributor(s)</strong>: Than Grove, Bill McGrath & Steve Weinberger</p><p class="paragraph">Check out the entire directory /texts/cocoon/essays/</p><p class="paragraph">All link URLs contained in any essay, including JIATS essays, are all located in one of two global files, both of which are found in the /texts/cocoon/essays folder:
</p><ol><li><strong class="bold">external-links.dtd</strong>: contains all links to sites <em class="italic">outside</em> of THL.</li>
<li><strong class="bold">internal-links.dtd</strong>: contains all links to internal THL pages.</li></ol><p class="paragraph">You must use Oxygen XML editor. UVa students, faculty, and staff can download it from this page: https://www.web.virginia.edu/rescomp/SoftwareInfo.asp?ID=44. <strong class="bold">Note:</strong> the installation instructions say do NOT install in the same folder as a previous version of Oxygen. They also say to put the file you download in a folder other than the folder where Oxygen will live on your hard drive (so download to desktop or somewhere like that).</p><p class="paragraph">Converting Sera Hermitages XML essays into new system for images:
</p><h3 class="heading-h3"><a name="Youonlyhavetodothefollowingelevenstepsthefirsttimeyourunthistransformation" class="anchorpoint"></a>You only have to do the following eleven steps the first time you run this transformation.</h3><p class="paragraph">
</p><ol><li>Open xml file to be transformed</li>
<li>Open essays/xsl/internal use/convertImgsToFigures.xsl</li>
<li>Click Configure Transformation Scenario tool in Oxygen toolbar</li>
<li>create a new scenario</li>
<li>name it (convert-essay)</li>
<li>XML URL: leave the default value</li>
<li>XSL URL: select convertImgsToFigures.xsl</li>
<li>Transformer: Saxon8B</li>
<li>Under Output tab, click "Save as" and "Open in editor" and Show as: xml</li>
<li>Click OK</li>
<li>Click "Transform now" button</li></ol><p class="paragraph">
</p><h3 class="heading-h3"><a name="ThefollowingprocedureneedstobeperformedoneachXMLfilethatyouaretransforming" class="anchorpoint"></a>The following procedure needs to be performed on each XML file that you are transforming</h3><p class="paragraph">
</p><ol><li>"Save file as" filename in the appropriate folder</li>
<li>At the top of the XML file, there is a comment <!--Links within Document-->:. Any links listed here that are not breadcrumbs still need to be updated</li>
<li>delete <xml-stylesheet href=""></li>
<li>Copy and paste DTD statement and any !ENTITY etc from the old xml file into the new file, right before <TEI.2></li>
<li>change location of the dtd to this: <img src="/" alt="external link: " title="external link"/><span class="nobr"><a href="http://www.thdl.org/global/xml/dtds/xtib3.dtd" target="rwikiexternal">http://www.thdl.org/global/xml/dtds/xtib3.dtd</a></span></li>
<li>Check to make sure it is xtib<span style="color: red;">3</span>.dtd and not xtib<span style="color: red;">2</span>.dtd</li>
<li>validate by clicking on checkmark icon that reads “Reset cache and validate”</li>
<li>If it doesn’t validate and the error is with <sourceDesc>, then on <sourceDesc> element, delete attribute default="NO"</li>
<li>Copy and paste : <div class="code"><pre><!ENTITY % extlinks SYSTEM "../external-links.dtd">
%extlinks;
<!ENTITY % intlinks SYSTEM "../internal-links.dtd">
%intlinks;
<!ENTITY glossary SYSTEM "glossaries/cabezon-sera-herm-gloss.xml"></pre></div> <strong class="bold">Note:</strong>The entity files are located in the /texts/cocoon/essays/xml file. So for JIATS, their location would be: "../../../essays/xml/external-links.dtd" Also, the location of the glossaries differs. In JIATS all glossaries are in the folder /texts/cocoon/jiats/xml/glossaries but in essays they are located within the letter sub-folder in a folder called glossaries (i.e., /texts/essays/xml/<em class="italic">{letter}</em>/glossaries/). Thus, if you add letter folders to /xml/, such as /xml/q/, then you also have to create a /glossaries subfolder for each folder that you added. In this case, /xml/q/glossaries/</li>
<li>Delete from new file any declaration that begins with !NOTATION, such as <!NOTATION HTML SYSTEM "html"></li>
<li>Move any entity declarations found in the top of the file into either the external-links.dtd file (for links outside of THDL) or the internal-links.dtd file (for THDL links). The names of THDL links should be reconfigured to represent its location within THDL, e.g. places-mons-sera.</li>
<li>Paste what you copied <!ENTITY …></li>
<li>Move the tag <name key="###" reg="thdl-participant"> into the <author> tag within the <titleStmt>. Change the tag-name to <persName key="###" reg="thdl-participant"> and within that enclose the author’s last name in <surname> tags.</li>
<li>Move <date> that was inside the <name> tag to outside the <persName> tag, but still within the <author></li>
<li>within <publicationStmt> , delete all the empty <respStmt>s and the old <author></li>
<li><respStmt>s that DO have content: move up to just after the <author> tag but within the <titleStmt></li>
<li><name key="per####" reg="thdl-participant"></li>
<li><publisher>: delete and replace with: &thdlpublisher;</li>
<li><pubPlace>: delete and replace with &thdlpubplace;</li>
<li><availability>: add this after <date> and before </publicationStmt></li>
<li>paste into the <availability> tag the following: <div class="code"><pre><p>
<bibl n=<span class="java-quote">"thdlloc"</span>>
<xref doc=<span class="java-quote">"thdl-places"</span> type=<span class="java-quote">"url"</span>>Places</xref>
<xref doc=<span class="java-quote">"thdl-places-mons"</span> type=<span class="java-quote">"url"</span>>Monasteries</xref>
<xref doc=<span class="java-quote">"thdl-places-mons-sera"</span> type=<span class="java-quote">"url"</span>>Sera Monastery</xref>
<xref doc=<span class="java-quote">"thdl-places-mons-sera-herm"</span> rend=<span class="java-quote">"home-link"</span> type=<span class="java-quote">"url"</span>>Hermitages</xref>
</bibl>
</p></pre></div> <br/> The attribute on the last <xref … rend="home-link" … > is what creates above the TOC a "home" link with the little house icon and the text within the xref. In this case, it creates the link "Hermitages" (with the home icon) above the TOC. If that rend attribute is absent, then no home link will appear above the TOC.</li>
<li><sourceDesc>: delete all content within it. Create the following <div class="code"><pre><sourceDesc>
<p>Essay written <span class="java-keyword">for</span> digital publication on THDL.</p>
</sourceDesc></pre></div></li>
<li><profileDesc>: delete entire. Replace with &thdlprofiledesc;</li>
<li>Add <back></back> after </body></li>
<li>For Sera Hermitage essays, <div class="code"><pre><back>
&glossary;
</back></pre></div></li>
<li>In <body>, delete <head>body</head></li>
<li>In <body> of essay, delete container <div1>. Change all top-level sections, currently marked as <div2>, to <div1>; change all <div3>s to <div2>s; etc. <strong class="bold">Note:</strong> THIS ONLY APPLIES TO THE BODY OF THE ESSAY.</li>
<li>Add ID attribute to EVERY <div> within the whole document. For <front>, first div is id="a1"; for <body>, first <div1> has id="b1"; first <div2> of first <div1> is <div2 id="b11>; second <div2> of first <div1> is <div2 id="b12">; <div3> of second <div2> of first <div1> is <div3 id="121"> etc.</li>
<li>Images: Each image needs to be located in the Media Management System (MMS). If not there, it needs to be uploaded to. The old mark-up for images was, e.g., <xref n="<img src="/" alt="external link: " title="external link"/><span class="nobr"><a href="http://www.imagelocation.com"" target="rwikiexternal">http://www.imagelocation.com"</a></span> type="image"> All such references need to be fixed. Correct markup: <br/><div class="code"><pre><figure entity=<span class="java-quote">"thdl-mms-images" n="<em class="italic">{MMS ID# for image here}</em>"</span>>
<figDesc>Caption text, with whatever markup is necessary, goes here.</figDesc>
</figure></pre></div>//A URL that locates the original image should be added in a comment,e.g., (<-- <em class="italic">comment text here </em> -->), in cases where the image has not yet been uploaded to the MMS.</li>
<li>Look at images after it is posted online. Make sure images are positioned in a way that is smooth and not jarring.</li>
<li>Images by default are floated right—displayed to the right of that paragraph of text.<ul class="star"><li>rend="left" moves image to the left of the paragraph</li>
<li>rend="center" text does NOT wrap around the image</li></ul>
</li>
<li>If you need to put two images side by side: <p rend="imgs">: displays images side by side; for the left-hand image, add <figure rend="left"></li>
<li>For Sera Hermitages essays, change the URL for images to: "http://ESSAYS-HOME/c/cabezon/{filename}". For JIATS an example is: "http://JIATS-IMG/03/jiats03elverskog_img1-sm.jpg"</li>
<li>Fix and check all links in document. The XSLT transformation done above will leave a list of all links in the document in a comment at the top. The old mark-up for a link was: <xref n="http://www.tbrc.org" type="url"><img src="/" alt="external link: " title="external link"/><span class="nobr"><a href="http://www.tbrc.org</xref>." target="rwikiexternal">http://www.tbrc.org</xref>.</a></span> The correct mark up for a link is: <xref doc="tbrc" type="url"><img src="/" alt="external link: " title="external link"/><span class="nobr"><a href="http://www.tbrc.org</xref>" target="rwikiexternal">http://www.tbrc.org</xref></a></span> where "tbrc" is the name of an entity (in this case) declared in the external-links.dtd file. Old link mark-up has to be changed to the new mark-up and the entities have to be created for a link if it doesn't already exist. Use entities to declare base-links that can be used with different variables and put the variable value in the n attribute of the <xref> tag. Thus, for the two TBRC links, <img src="/" alt="external link: " title="external link"/><span class="nobr"><a href="http://www.tbrc.org/kb/tbrc-detail.xq?RID=P1583" target="rwikiexternal">http://www.tbrc.org/kb/tbrc-detail.xq?RID=P1583</a></span> and <img src="/" alt="external link: " title="external link"/><span class="nobr"><a href="http://www.tbrc.org/kb/tbrc-detail.xq?RID=P1709." target="rwikiexternal">http://www.tbrc.org/kb/tbrc-detail.xq?RID=P1709.</a></span> There is a single entity you would use "tbrc-search" which is defined as <div class="code"><pre><!ENTITY tbrc-search SYSTEM <span class="java-quote">"http://tbrc.org/kb/tbrc-detail.xq?RID="</span> NDATA HTML ></pre></div>. Then, the individual <xref>s would be: <xref doc="tbrc-search" n="P1583" type="url">Dri med 'od zer</xref> and <xref doc="tbrc-search" n="P1709" type="url">Chos dbyings stobs ldan rdo rje</xref>. Before adding a link entity, however, check to make sure the link is still valid. If not, ask the author for an updated link or if the link should be removed. So, for each link, you need to:<ol><li>Check URL to make sure it is active and goes to the correct page.</li>
<li>Move each entity to the external-links.dtd file, fix the name if necessary, and then fix the doc="" value in the essay itself.</li></ol>
</li>
<li>URL for a Sera Hermitage Essays: directory path/#essay=/cabezon/sera/herm/drakri/</li></ol><p class="paragraph">
</p><h3 class="heading-h6"><a name="ProvidedforunrestrictedusebythespanclassnobrimgsrcsakairwikitoolimagesicklearrowgifaltexternallinktitleexternallinkahrefhttpwwwthdlorgtargetrwikiexternalTibetanandHimalayanLibraryaspan" class="anchorpoint"></a><em class="italic">Provided for unrestricted use by the <span class="nobr"><img src="/" alt="external link: " title="external link"/><a href="http://www.thdl.org" target="rwikiexternal">Tibetan and Himalayan Library</a></span></em></h3>