Great!<br><br>Yes, Oxygen's main strength is surely those red squiggly lines.<br><br>I could try explaining those Xpath expressions, but it would turn into an essay. XSL is weird.<br><br>j<br><br><div class="gmail_quote">
On 1 March 2011 13:56, Aidan Wilson <span dir="ltr"><<a href="mailto:aidan.wilson@unimelb.edu.au">aidan.wilson@unimelb.edu.au</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
John, your variable xsl element worked. I had to fiddle with what you gave me quite a bit, but oxygen just paid for itself giving me all the red squiggly lines showing me where every xsl/xml error was. Here's what I came up with and below is a sample from the output.<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="im">
<xsl:for-each select="Words[Status!='Exclude']/Meanings/Reverse"><br></div>
<xsl:sort select="."/><br>
<xsl:sort select="../../Headword"/><br>
<xsl:variable name="this_word" select="."></xsl:variable><br>
<xsl:choose><br>
<xsl:when test="$this_word = ancestor::Words/preceding-sibling::Words[Status!='Exclude']/Meanings/Reverse"></xsl:when><br>
<xsl:otherwise><br/><strong><xsl:value-of select="."/></strong><br/></xsl:otherwise><br>
</xsl:choose><br>
<xsl:value-of select="../../Headword"/><br/><br>
</xsl:for-each><br>
</blockquote>
<br>
Output (sample):<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
arm<br>
lari<br>
<br>
armlets<br>
binbin<br>
yerrel<br>
<br>
armpit<br>
wanganyjarri<br>
<br>
armpit sweat<br>
langornen<br>
<br>
around<br>
dabali-ma<br>
wirriny-nya<br>
</blockquote>
<br>
So again, thanks heaps! (I don't quite understand the intricate details of ancestor::Words/preceding-sibling blah blah, but that doesn't matter).<br>
<br>
-Aidan<br>
<br>
-- <br><div class="im">
Aidan Wilson<br>
<br>
PhD Candidate<br>
Dept of Linguistics and Applied Linguistics<br>
The University of Melbourne<br>
<br>
+61428 458 969<br>
</div><font color="#888888"><a href="mailto:aidan.wilson@unimelb.edu.au" target="_blank">aidan.wilson@unimelb.edu.au</a></font><div><div></div><div class="h5"><br>
<br>
On Tue, 1 Mar 2011, Aidan Wilson wrote:<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Thanks for your help, John (et al.). I'll look into that for the de-suplication of reverse elements when I get time.<br>
<br>
Tom Honeyman had a quicker solution for sorting the entire list of reverse elements with respect to each other, and not within sets of 'Words' elements, and that was to group the two <xsl:for-each together, so instead of:<br>
<xsl:for-each select="Words[Status!='Exclude']"><br>
<xsl:for-each select="Meanings/Reverse"><br>
I now have just:<br>
<xsl:for-each select="Words[Status!='Exclude']/Meanings/Reverse"><br>
<br>
The way I had it meant I was selecting each word, and within that set, each Reverse element, which was where the sort was having trouble. This selection now works brilliantly.<br>
<br>
-Aidan<br>
<br>
On Mon, 28 Feb 2011, John Mansfield wrote:<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi Aidan,<br>
I will try to help. First I'll discuss your issue about sorting according to<br>
Reverse elements, then secondly I'll address your "ideal" solution of not<br>
duplicating identical Reverse elements.<br>
<br>
1. If you want to have all the Reverse elements in the source sorted as a<br>
single list, rather than a series of sorted lists, one for each Headword,<br>
then I think your problem is that you are doing your sort inside this<br>
for-each loop:<br>
<xsl:for-each select="Words[Status!='Exclude']"><br>
<br>
So you need a template structure that goes directly from the<br>
whole-dictionary level right to the Reverse elements, rather than getting to<br>
them via the Words wrappers. Does that make sense? Maybe something like:<br>
<br>
<xsl:template match="Dictionary"><br>
<xsl:for-each select="//Reverse"><br>
<xsl:sort select="."/><br>
<p><b><xsl:value-of select="."/></b></p><br>
<xsl:value:of select="ancestor::Words/Headword"/><br>
</xsl:for-each><br>
</xsl:template><br>
<br>
PS: another way of sorting in xsl is with an attribute @order-by on the<br>
<for-each element. I don't know what the difference is between the methods,<br>
and it may be arcane.<br>
<br>
<br>
2. As for de-duplicating the Reverse elements: I don't think XSL is a<br>
particularly good tool for it; it's not a very good framework for comparing<br>
strings... and when you want to extract wordlists from data, you often get<br>
sets of things that are not identical character-by-character, but you would<br>
like to have treated as one.<br>
<br>
That said, it might work if you have a condition, simply asking at each<br>
Reverse element, "have I already displayed a Reverse element like this one?"<br>
And if not, then display it, but alongside display not just it's own<br>
Headword sibling, but the Headwords of each Reverse elements with that<br>
value.<br>
Code could be something like this:<br>
<br>
<xsl:template match="Dictionary"><br>
<xsl:for-each select="//Reverse"><br>
<xsl:sort select="."/><br>
<!-- I'm not sure if you need this variable, but you might need it for<br>
the output bit below--><br>
<xsl:variable name="this_word" select="."/><br>
<xsl:choose><br>
<xsl:when test="$this_word =<br>
ancestor::Words/preceding-sibling::Words//Reverse"><br>
<!-- no output - we've seen this Reverse before --><br>
</xsl:when><br>
<xsl:otherwise><br>
<!-- output the Reverse element --><br>
<p><b><xsl:value-of select="."/></b></p><br>
<!-- for each Words element that has this Reverse word in it,<br>
output the Headword --><br>
<xsl:for-each<br>
select="ancestor::Words/preceding-sibling::Words[descendent::Reverse =<br>
$this_word]<br>
or ancestor::Words/following-sibling::Words[descendent::Reverse =<br>
$this_word]"><br>
<xsl:value:of select="Headword"/><br>
</xsl:for-each><br>
</xsl:otherwise><br>
</xsl:for-each><br>
</xsl:template><br>
<br>
I don't know if that will work, but it seems like it should.<br>
<br>
j<br>
<br>
On 28 February 2011 15:30, Aidan Wilson <<a href="mailto:a.wilson@pgrad.unimelb.edu.au" target="_blank">a.wilson@pgrad.unimelb.edu.au</a>><br>
wrote:<br>
Hi RNLDers (I still prefer "Ronaldos")<br>
<br>
Does anyone have fairly good XSL skills and could guide me<br>
through a particularly nasty dictionary formatting issue?<br>
<br>
The problem is that I have a reverse word finder which is built<br>
by extracting an element from each headword ('Reverse' which was<br>
originally put in for exactly this purpose). Here's an example<br>
of a word's XML (totally made up<br>
example to demonstrate the point):<br>
<br>
<Words><br>
<Headword>elevate</Headword><br>
<Category>verb</Category><br>
<Meanings><br>
<Definition>to raise, to lift</Definition><br>
<Reverse>raise</Reverse><br>
<Reverse>lift</Reverse><br>
<Examples><br>
<Example>You need to elevate your blood pressure</Example><br>
<Translation>You need to raise your blood<br>
pressure</Translation><br>
</Examples><br>
</Meanings><br>
</Words><br>
<br>
The difficulty is that some words will have more than one<br>
Reverse element (as above). At the moment I can either:<br>
a) Extract only the first reverse element from each entry,<br>
display it next to the headword, and all will be in alphabetical<br>
order by the Reverse element, or<br>
b) Extract all reverse elements from all headwords, and display<br>
each one next to its headword, but they will be ordered *within<br>
the set of reverse elements of that word.<br>
<br>
What I mean by that, is that I can get it working so I can<br>
produce:<br>
<br>
Lift:<br>
elevate<br>
<br>
Raise:<br>
elevate<br>
<br>
But the Reverse elements from any other words will be sorted<br>
amongst themselves, but independently of any other word. So what<br>
I get in my English to Wagiman section is essentially ordered by<br>
the Wagiman word, but each word's<br>
English glosses sorted among themselves.<br>
<br>
What I would like is to pair each reverse element with its<br>
headword and then sort the whole list for the whole dictionary<br>
at once.<br>
<br>
Ideally, actually, I'd like to group together identical Reverse<br>
elements so that I could have something like:<br>
<br>
Lift:<br>
boost<br>
elevate<br>
heighten<br>
raise<br>
<br>
Instead of listing them separately.<br>
<br>
Here's the relevant section of my xsl stylesheet:<br>
<br>
<xsl:for-each select="Words[Status!='Exclude']"><br>
<xsl:sort select="Meanings/Reverse"/><br>
<xsl:for-each select="Meanings/Reverse"><br>
<p><strong><xsl:value-of<br>
select="."/></strong><br/><br>
<xsl:value-of select="../../Headword"/></p><br>
</xsl:for-each><br>
</xsl:for-each><br>
<br>
Hopefully this isn't an impossible task. And hopefully someone<br>
knows more than my week's worth of xsl and can point me in the<br>
right direction!<br>
<br>
--<br>
Aidan Wilson<br>
<br>
PhD Candidate<br>
Dept of Linguistics and Applied Linguistics<br>
The University of Melbourne<br>
<br>
+61428 458 969<br>
<a href="mailto:a.wilson@pgrad.unimelb.edu.au" target="_blank">a.wilson@pgrad.unimelb.edu.au</a><br>
<br>
<br>
<br>
<br>
</blockquote>
<br>
</blockquote>
</div></div></blockquote></div><br>