[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Generating a <div>-toggling ID as a variable

Subject: Generating a <div>-toggling ID as a variable
From: "Charles Muller acmuller@xxxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 9 Jan 2017 05:32:43 -0000
 Generating a <div>-toggling ID as a variable
Dear XSLT'ers,

I am trying to help a student in my XML class solve a problem for which I'm not sure there is a solution.

She is encoding and transforming a Sino-Japanese character dictionary done with the TEI dictionaries recommendations. Like all standard dictionaries of this type, the format is that of a single kanji headword with pronunciation and definition(s), followed by compound words with pronunciation and definitions. A simplified presentation of the data looks like this:

<entry xml:id="m117">
    <pron xml:lang="ja-hb">sai</pron>
    <sense><def>A wasting disease</def></sense>

        <pron xml:lang="ja-hb">saiyu</pron></form>
    <pron xml:lang="ja-hb">rE
</form>  <sense><def>consumption</def><def>wasting</def></sense>

<entry xml:id="m118">
    <orth>e5</orth> ...

The <hom> tag was used arbitrarily to wrap a set of <re> tags (transforming into a <div> in HTML), because the student would like to toggle the view of the compound words in a single set, which are now wrapped by <hom>.

Writing the javascript and HTML code to toggle one section based on a <div> ID is no problem, but in order for each <hom> section of each of the many <entry(s)> in the dictionary to be toggled individually, each one would need its own separate ID to be generated. I've spent a couple of hours researching this, and from what I've found, I'm not sure if it's possible.

The Javascript in the header looks like this:

              function myFunction(id) {
              var x = document.getElementById('myDIV');
              if (x.style.display == 'none') {
              x.style.display = 'block';
              } else
              x.style.display = 'none';

And the XSLT at the toggle point down below looks like this:

<xsl:template match="dictScrap">
<button onclick="myFunction(id);return false;">Show related words</button>


    <xsl:template match="hom">
        <div id="myDIV" style="display: none"><xsl:apply-templates/></div>

So the crux of the matter seems to be whether the 'myDIV' that is used in the Javascript function, which appears as the <div id> below, can be turned into a variable that will function separately for each entry. Does anyone know if this is possible?


A. Charles Muller

Graduate School of Humanities and Sociology
Faculty of Letters
University of Tokyo
7-3-1 HongE
, BunkyE
Tokyo 113-8654, Japan

Office Phone: 03-5841-3735

Web Site: Resources for East Asian Language and Thought

Twitter: @H_Buddhism

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.