Re: [xsl] unfolding compressed equivalents

Subject: Re: [xsl] unfolding compressed equivalents
From: Robert Koberg <rob@xxxxxxxxxx>
Date: Wed, 23 Jan 2008 16:17:49 -0500
Hi,

You have laid out the problem well. But, you should probably follow up
with some of the problematic XSL you have tried.

best,
-Rob


On Wed, 2008-01-23 at 21:25 +0100, Marie Bilde Rasmussen wrote:
> Hi,
> 
> I have been struggling with a tricky transformation-problem. Maybe
> somebody can help me come up with a good xslt-solution.
> 
> THE BACKGROUND:
> In dictionary entries, text is very often compressed in order to save
> space/paper. But these entries can be very hard to read. When
> publishing a bilingual dictionary online, I would like to unfold each
> equivalent to all of the equivalents, that are postulated to exist in
> it's originally compressed structure.
> 
> AN EXAMPLE:
> In a Danish-English dictionary, I have this extremely compressed
> English equivalent(s):
> "[last] Sunday (or Monday or Tuesday) evening (or night) I was at home"
> 
> - The use of [square brackets] indicate, that the content can be omitted.
> - Alternatives to a word - or to a sequence of words - are shown in
> one (parenthesis), separated by the word "or".
> - Brackets, parenthesis and or's are of course just presentational.
> 
> The data are represented in xml like this:
> <equivalent>
>     <omittable>last</omittable>
>     { }
>     <either>Sunday</either>
>     <or>Monday</or>
>     <or>Tuesday</or>
>     { }
>     <either>evening</either>
>     <or>night</or>
>     { I was at home}
> </equivalent>
> 
>  I have shown the text content on the top level in {curly braces}
> 
> The rules about equivalents are (here simplified for the example):
> - An either-element must be immediately followed by at least one or-element
> - There can be zero, one or several omittable-elements in an equivalent
> - There can be zero, one or several either/or-constructions in an equivalent
> - The equivalents have mixed content
> 
> The xml-schema fragment describing such a compressable equivalent is as follows:
> <xs:element name="equivalent">
>     <xs:complexType mixed ="true">
>         <xs:choice minOccurs="0" macOccurs="unbounded">
>             <xs:sequence>
>                 <xs:element name="either" type="xs:string"/>
>                 <xs:element name="or" macOccurs="unbounded" type="xs:string"/>
>             </xs:sequence>
>             <xs:element name="omittable" type="xs:string"/>
>         </xs:choice>
>     </xs:complexType>
> </xs:element>
> 
> THE GOAL:
> In my online dictionary, I would like to show this same equivalent like this:
> 
> 1. last Sunday evening I was at home
> 2. last Sunday night I was at home
> 3. last Monday evening I was at home
> 4. last Monday night I was at home
> 5. last Tuesday evening I was at home
> 6. last Tuesday night I was at home
> 7. Sunday evening I was at home
> 8. Sunday night I was at home
> 9. Monday evening I was at home
> 10. Monday night I was at home
> 11. Tuesday evening I was at home
> 12. Tuesday night I was at home
> 
> The resulting underlying xml should thus look like this:
> <equivalent>last Sunday evening I was at home</equivalent>
> <equivalent>last Sunday night I was at home</equivalent>
> <equivalent>last Monday evening I was at home</equivalent>
> <equivalent>last Monday night I was at home</equivalent>
> <equivalent>last Tuesday evening I was at home</equivalent>
> <equivalent>last Tuesday night I was at home</equivalent>
> <equivalent>Sunday evening I was at home</equivalent>
> <equivalent>Sunday night I was at home</equivalent>
> <equivalent>Monday evening I was at home</equivalent>
> <equivalent>Monday night I was at home</equivalent>
> <equivalent>Tuesday evening I was at home</equivalent>
> <equivalent>Tuesday night I was at home</equivalent>
> 
> Can anyone help me through function-calls and recursions? I am using XSLT 2.0.
> 
> Best regards,
> Marie
> 
> PS The example was chosen for it's structural clarity only -
> definitely not as an example of lexicographical best-practices
> 
> **********
> Marie Bilde Rasmussen
> Content architect, MA, BSc
> Gyldendal Publishers
> Copenhagen, Denmark
> 
> marie_bilde@xxxxxxxxxxxx
> mariebilderas@xxxxxxxxx

Current Thread