File Naming And Storage Conventions For Thdl > Code Editing Tools

THL Toolbox > Developers' Zone > Web Development > Code Editing Tools

Code Editing Tools

Contributors: Than Grove, Steven Weinberger

Quick links: oXygen | Free Text Editors

oXygen Text Editor

We recommend using oXygen to edit XML, XSL, and PHP files.

Configuring oXygen

To configure oXygen, pull down the Options menu and select Preferences. Keep all the default settings but CHANGE the following values:

  1. FONTS (in lefthand nav under "Appearance")
    1. For Mac: set Editor, Author Default Font, Text Components, and GUI to a Unicode Font, such as Times New Roman, Gentium, Arial Unicode MS, etc. Set Schema Default font to SansSerif. If you are working with Tibetan text in XML or PHP files, you need to set Editor to a unicode Tibetan font such as Jomolhari-ID or Kailasa.
    2. For Windows: set Editor, Author Default Font, Text Components, and GUI to a Unicode Font, such as Times New Roman, Arial Unicode MS, etc. Set Schema Default font to SanSerif. If you are working with Tibetan text in XML or PHP files, you need to set Editor to a unicode Tibetan font such as Jomolhari-ID or TibetanMachineUni.
  2. ENCODING: set Encoding for Fallback character encoding and Encoding for Base64… to UTF-8; set Encoding Errors Handling to IGNORE
  3. Editor > Format (under "Editor"): check every box EXCEPT "Indent with tabs" and "Clear undo buffer before Format and Indent"
  4. Editor > Format > XML: uncheck "Preserve line breaks in attributes" and "Break long attributes"
  5. OPEN/SAVE: set Disable special characters support for documents larger than (characters) to: 800000
  6. Sample XML Files Generator (under "XML"): Preferred number of repetitions: 3
  7. XML > XSLT-FO-XQuery > XQuery > SAXON-HE/PE/EE:
    1. set Recoverable errors ("-warnings") to: Recover with warnings ("recover")
    2. set Strip whitespaces to: Ignore ("ignorable")
    3. set Validation of the source file to: Schema validation ("strict")
  8. XML > XSLT-FO-XQuery > XSLT > Saxon > Saxon-HE/PE/EE:
    1. set Strip whitespaces to: Ignore ("ignorable")
    2. set Validation of the source file to: Schema validation ("strict")
  9. DIFF > Files Comparison:
    1. check Ignore whitespaces
  10. DIFF > Directories Comparison:
    1. check Look inside archives
  11. Network Connection Settings > HTTP(S)/WebDAV: set Read timeout (seconds) to: 30

If when you open an XML file the Tibetan font appears as square boxes, do the following;

  1. Make sure that you have configured the font settings as described above
  2. In preferences, make sure that auto format/indent is selected (Tibetan font in a file doesn't display properly if there are super long lines in the file)
  3. Save the file
  4. Close the file and reopen it
  5. If that doesn't work, quit oXygen and then relaunch it, and reopen the file

Searches in oXygen

Regular Expression Search

In oXygen, you do a search on the glossary and make sure that "Regular Expression" is checked. Then you search for:

<term lang="chi" rend="([^"]+)">([^<]+)</term>

and replace that with:

<term lang="chi">$2 <foreign lang="chi" rend="chi parens">$1</foreign></term>

The parentheses are areas where you want to store the value so the first set is equal to $1 and the second $2. Phrases like [^"]+ means one or more characters (+) that are part of the set ([]) that are NOT (^) the " character.

Find element that does not have a particular @

  1. In the XPath search box enter: /*//placeName[not(@lang)]
  2. This will return all <placeName> tags that do not have a lang attribute

Find (and delete) all @rend="parenval" for elements with @lang="chi"

  1. Open the oXygen Search box for the article.
  2. Make sure that "Enable XML search options" is NOT checked
  3. In the "Search for" field enter: rend="parenval"
  4. In the "XPath" field enter: /*//*[@lang="chi" and @rend="parenval"]
  5. Press Find all. This will find all instances
  6. After you have made sure you want to delete all of the rend="parenval" @s:
    1. In the "Replace with" field enter: {nothing}
    2. Press Replace all

Search for element with a particular @ and value and without a different @ and value

In the XPath 2.0 search box in the toolbar at the top left of the oXygen window enter:

  1. /*//placeName[contains(.,'gu ge') and not(@lang)]: this will search for <placeName>gu ge&#lt;/placeName> that does not have a lang @
  2. /*//placeName[not(@corresp) and lang='tib']: this will search for <placeName> that has no corresp value and has lang='tib'.
    1. /*//placeName[(not(@corresp) or @corresp='') and lang='tib']: in case there is a case where there is a placeName element and the corresp attribute has no value (<placeName corresp="">)

Search for an element with and/or without specific attributes and a particular value in Search/Replace in Files

  1. In the Restrict to XPath box enter: /*//persName[contains(.,'thar lo') and not(@lang)]
  2. In the Text to Find box enter "thar" (just one syllable of the value you are searching for)
  3. Click "Find All"

It will return all occurrences of <persName> element that does NOT have @lang and that has as part of its value thar

Search for an element with a particular value, with an @, and without another @

  1. Text to Find box: mon
  2. Restrict to XPath box: /*//placeName[contains(.,'mon dur') and (@lang='tib') and not(@corresp)]

This will return all <placeName lang="tib"> that contain mon dur in the value AND that do NOT have corresp=""

Search for an element within another element

  1. /*//term[parent::head] this will search for <term> inside <head> tag
  2. To limit the search to the <body> of the file: /*//body//term[parent::head]

Search for Chinese font without @rend="chi"

  1. Open the search box
  2. check the "Regular Expression" box
  3. in the Text to find field enter: [〤-﨩]+
  4. in the Xpath box enter: /*//text()[not(ancestor::*/@rend='chi')]

Search for an Arabic Number that Is Not the Value of an Element

To search on an arabic number like 5 and search for instances that are not values of an element:
In the find dialog box:

  1. Enter "d+" in Text to Find
  2. In the XPath text box put: /*//text()[ancestor::text and not(parent::num) and not(parent::milestone)] Note: the file must validate in order to use the XPath search
  3. Select "Regular expression"
  4. Select Enable XML Search
  5. Under Enable XML search options select "Element Contents"

Running XSLT to reapply pinyin

To run an XSLT to repopulate the pinyin in an article or essay XML file with the value in a file of modified glossary entries:

Configure oXygen

  1. Pull down options menu > preferences >
    1. under XML > XSLT-FO-XQuery > XSLT > Saxon > Saxon-HE/PE/EE
      1. under Saxon-HE/PE/EE options, deselect Version warnings
      2. under Saxon-PE/EE options, select Allow calls on extension functions
      3. under the heading Saxon-EE specific options, set Validation of the source file to: Lax schema validation ("lax")
  2. Create a new XML file and copy and paste modified glossary entries into it
  3. Wrap the entries in a &lt;div> tag.

Procedure for running the XSL transformation:

  1. Open the original document in oXygen and comment out the following parts of the original document:
    1. The DOCTYPE definition and all that's included in it before the TEI.2 element.
    2. The entity declarations such as &thdlpublisher; &thdlpubplace; and &thdlprofiledesc;
    3. The glossary declaration &glossary;
    4. Any uses of the &lt;![CDATA[ ]]> statement such as in the &lt;title type="citation">.
  2. Then open the file FixJiats06Pinyin.xsl
  3. In the XSL file change <xsl:variable name="docname">tuttle-06-glossary-entries-modified.xml</xsl:variable>

to the name of the XML file with the revised entries in it

  1. Make active the original article XML file
  2. Click the wrench icon (Configure Transformation Scenario, ctrl+shift+c) to create a transformation scenario
  3. Click "New" and enter a name, like "tuttle-gloss-new"
    1. In the XML field it should have: ${currentFileURL}
    2. In the XSL field choose FixJiats06Pinyin.xsl
    3. In the transformer field select Saxon-EE 9.3…
    4. Click OK. This creates the scenario.
  4. Click Transform Now!
  5. The XSLT will run and transform the file.
  6. Then, uncomment everything you commented out and validate.

Back to top

Free Text Editors

For free text editors to run in Windows, we suggest Komodo Edit. You could also try TextPad.
Note: these are provisional recommendations; we have not tested these extensively.

Provided for unrestricted use by the external link: Tibetan and Himalayan Library