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

mixed content, text-based abbreviations to xml

Subject: mixed content, text-based abbreviations to xml
From: James Cummings <james+xsl@xxxxxxxxxxxxxxxxx>
Date: Thu, 5 Mar 2009 16:32:33 +0000
 mixed content
[resending after bounce message...because the mailing list doesn't
like google app's different X-MAIL-FROM header...fingers crossed it is
right now.]

Hiya,

I have some XML that has mixed content of markup and text nodes where
I want to process certain words. B The words in the the document are
not already tokenized in any way (and multiple levels of nested markup
ranging from the middle of words makes this difficult). B What I want
to do is process the individual words (some containing or embedded in
markup) and where there is an expansion denoted by parentheses provide
that and the abbreviated form, and if that works, then if there is a
<supplied> element beginning and ending inside the word, replace that
with <damage/> to provide a copy of the original.

If the content is something like:

=====
<p>
B  B <lb n="1"/>In nomine Domini amen. Ne error obliuionis
<supplied>geE?tis</supplied> E?ub tempore
B  B verE?antibus pariat detrimentu(m). <lb n="2"/>Conuenit, ut actus
h<supplied>om</supplied>inu(m)
B  B  B  B l(itte)r<supplied>ar</supplied>(um) et teE?tium fidedignorum
<seg>annotac(i)on(e)</seg> ad
B  B poE?teritatis noticiam <foo>deducantur <seg>aut int(er)dum</seg>
ob</foo> scripture vetustatem
B  B renovent(ur). Ad perpetuam proinde ...
</p>
=====

The output should change words containing ( and ) into a nested
structure such as:

input: h<supplied type="damage">om</supplied>inu(m)
output:
<choice>
B  B <orig>h<damage/>inu<am/></orig>
B  B <abbr>h<supplied type="damage">om</supplied>inu<am/></abbr>
B  B <expan>h<supplied type="damage">om</supplied>inu<ex>m</ex></expan>
</choice>

The <orig> is only supplied here because the original word actually
has a <supplied reason="damage"> element that begins/ends inside the
word. (For the full example I've not included the attribute to make it
more readable.) B Words can contain any number of elements such as
<lb/> and <supplied>, as well as the usual whitespace problems.
Abbreviations denoted by parentheses are always only part of an
individual word, though may occur multiple times in a word.

Full output of the above would be something like:
=====
<p>
B  B <lb n="1"/>In nomine Domini amen. Ne error obliuionis
<supplied>geE?tis</supplied> E?ub tempore
B  B verE?antibus pariat <choice>
B  B  B  B <abbr>detrimentu<am/></abbr>
B  B  B  B <expan>detrimentu<ex>m</ex></expan>
B  B </choice>. <lb n="2"/>Conuenit, ut actus <choice>
B  B  B  B <orig>h<damage/>inu<am/></orig>
B  B  B  B <abbr>h<supplied>om</supplied>inu<am/></abbr>
B  B  B  B <expan>h<supplied>om</supplied>inu<ex>m</ex></expan>
B  B </choice>
B  B <choice>
B  B  B  B <orig>l<am/>r<damage/><am/></orig>
B  B  B  B <abbr>l<am/>r<supplied>ar</supplied><am/></abbr>
B  B  B  B <expan>l<ex>itte</ex>r<supplied>ar</supplied><ex>um</ex></expan>
B  B </choice> et teE?tium fidedignorum <seg>
B  B  B  B <choice>
B  B  B  B  B  B <abbr>annotac<am/>on<am/></abbr>
B  B  B  B  B  B <expan>annotac<ex>i</ex>on<ex>e</ex></expan>
B  B  B  B </choice>
B  B </seg> ad poE?teritatis noticiam <foo>deducantur <seg>aut <choice>
B  B  B  B  B  B  B  B <abbr>int<am/>dum</abbr>
B  B  B  B  B  B  B  B <expan>int<ex>er</ex>dum</expan>
B  B  B  B  B  B </choice>
B  B  B  B </seg> ob</foo> scripture vetustatem <choice>
B  B  B  B <abbr>renovent<am/></abbr>
B  B  B  B <expan>renovent<ex>ur</ex></expan>
B  B  B  B </choice>. Ad perpetuam proinde ...
</p>
=====

The default copying-to-output, choices between things and creating the
different versions of things once I have each word and its
abbreviations tokenized all seems straightforward. B It is getting each
word, without losing any other markup, and knowing where the
abbreviations are that I'm more fuzzy about. B I hate asking for help
before I've got very far, but it is straying into territory I'm not
very familiar with. B I'm guessing that this needs a multi-pass
mode-based stylesheet with xsl:analyze-string to find the parentheses,
but not tokenize() to find the edges of the word but, erm, maybe
xsl:for-each-group? While I found individual bits of this in the FAQ I
didn't find anything doing it all at once.

Any suggestions ranging from pointers in the right direction to
fully-realized solutions gratefully received with promises of a pint
next time you're in Oxford. ;-)

Many thanks,
-James Cummings
(posting from a new and silly domain name)

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-2007 All Rights Reserved.