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

Building cross-referenced texts with XSLT

Subject: Building cross-referenced texts with XSLT
From: Aaron Optimizer Digulla <digulla@xxxxxxxx>
Date: Sun, 25 Aug 2002 20:56:58 +0200
xslt preserving entities
Hello,

I've got a large database (roughly 1MB) which contains comics,
stories and characters by Stan Sakai. Here is an example:

    <characters>
        <character id="atsuko">
            <name></name>
            <prename>Atsuko</prename>
            <first-story ref="frost-and-fire"/>
            <first-issue ref="uy-vol1-nr19"/>
            <death ref="frost-and-fire"/>
            <caste>Peasant</caste>
            <profession></profession>
            <fight-prof></fight-prof>
            <weapon></weapon>
            <anthro>Feline</anthro>
            <clan>Geishu</clan>
            <quote></quote>
            <img url="$TOP/uywho/atsuko.gif"
                icon="$TOP/uywho/icon/atsuko.gif"
            />
            <note>"<em>Atsuko</em>" means Hot Child</note>
            <profile>

<p>A peasant girl who possessed swords belonging to a Samurai named &Nagao;.
&Nagao; and Atsuko were in love and had planned to commit lovers suicide
before &Nagao; was killed by Atsuko's brother for money.</p>

<p>Unaware of this, Atsuko kept the swords as a memento of her lost love.
&Usagi;, hired by &Nagao;'s widow - Lady <char-link ref="lady-koriko"/>, to
retrieve the swords, offered to pay for the return of the swords. Atsuko
refused and &Usagi; left. Atsuko and her brother argued about the swords,
her brother trying to take them by force, accidentally killing her.</p>

            </profile>
        </character>

As you can see, the text contains lots of entities which are defined
like this:

<!ENTITY Nagao '<char-link ref="nagao">Nagao</char-link>'>
<!ENTITY LadyAsano '<char-link ref="asano">Lady Asano</char-link>'>

How can I write a script that converts "Lady Asano" into &LadyAsano;
and "Nagao" into &Nagao; but which leaves &Nagao; (or the expanded
entity) alone?

Note that preserving the entities is not a problem; I can easily
convert the expanded form back into the entity notation should I
have to. But how do I transform char content in specific elements
while not doing it in other elements?

How do I make sure that "Lady Asano" is transformed into &LadyAsano;
while "Asano" is transformed into &Asano; while
"<char-link ref="asano">Lady Asano</char-link>" should be left alone?
Note that I have about 2-300 entities to check.

Also, I would like to suppress the expansion of "Atsuko" inside
of her description.

And the original layout (whitespace) should be preserved (ie.
I don't want "hired by &Nagao;" become "hired by&Nagao;").

Any ideas?

-- 
==============================================
Sowatec AG,       CH-8330 Pfäffikon (ZH)
Witzbergstr. 7,   http://www.sowatec.com
Tel: +41-(0)1-952 55 55
Fax: +41-(0)1-952 55 66
----------------------------------------------
Aaron "Optimizer" Digulla, digulla@xxxxxxxxxxx
==============================================

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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.
Email
First Name
Last Name
Company
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.