[xsl] Replacing specific acronyms in output

Subject: [xsl] Replacing specific acronyms in output
From: "thei" <thei@xxxxxxxxx>
Date: Fri, 13 Feb 2004 18:10:42 +1000
Hello,

I've a journal, which stores its data in an XML file. I use XSLT to
dynamically transform this into various output formats - XHTML in this
case, based on various criteria such as the date to display and so on.
The XSLT used to do this transformation is available here
http://nedmartin.org/journal/xsl/ , although it is probably not very
relevant to my question. 'day.xsl' shows single days; 'full.xsl' shows
full years and so forth. 'journal-imports.xsl' does the actual
transformation.

I also have an XML list of acronyms used throughout my journal,
formatted thus:
<acronyms>
  <acronym acronym="CSS">Cascading Style Sheet</acronym> 
  <acronym acronym="CGI">Common Gateway Interface (web scripting
facility) or Computer-Generated Imagery (movie industry)</acronym>
  ...
</acronyms>

I wish to be able to automatically replace any occurrence of an acronym
in the XHTML output with the appropriate XHTML <acronym title="Cascading
Style Sheet">CSS</acronym> tag.

I have thought about it and I can't think of any way to do this that
wouldn't involve parsing my journal and on every single word of my
journal, parsing every single acronym in my acronyms list - thus for
every word in my journal my entire acronym list would be parsed -
something I assume would be highly inefficient.

In case it matters, my journal is in the format:
<journal>
  <year date="2004">
    <month date="01">
      <day date="01>
        <content time="...">blah blah</content>
        ...
      ...
    <month date="02">
    ...
  </year>
</journal>
or view the schema: http://nedmartin.org/journal/xsl/journal.xsd


There has to be a good way to do this?

Help much appreciated,
Ned

Printed on 100% recycled electrons.
http://nedmartin.org




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


Current Thread