|
Subject:
|
referenced entities
|
|
Posted By:
|
bcogney
|
Post Date:
|
4/20/2006 2:34:12 PM
|
need help to order these names alphabetically <titltxt>Ōkubo Toshimichi</titltxt> <titltxt>adam</titltxt> <titltxt>sam</titltxt> <titltxt>keven</titltxt>
Michael suggested using this:
<xsl:template match="articles"> <xsl:for-each select="article"> <xsl:sort select="title"/> <xsl:copy-of select="."/> </xsl:for-each> </xsl:template>
works fine till I run into referenced entities before the names to be ordered.
thanks Bill
|
|
Reply By:
|
mhkay
|
Reply Date:
|
4/21/2006 3:24:21 AM
|
You don't say what result you're getting or what result you're expecting, so it's difficult to help. Entity references are expanded long before the sort takes place. You don't say what the expansion of &OMacr; is, but I imagine it's probably a capital O with macron. Collating sequences are implementation-defined and depend on the chosen language or locale, but unless there are special rules for your locale I would normally expect "Ōkubo" to sort after "Okubo" and before "Okubp". However, some XSLT processors might use simple codepoint-based sorting and there's nothing in the spec that disallows this.
Michael Kay http://www.saxonica.com/ Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
|
|
Reply By:
|
bcogney
|
Reply Date:
|
4/21/2006 9:55:47 AM
|
well Michael, that the issue I didn't mention...I don't want these entities to be expanded in transformation.
and regarding the desired results, if I have these words (entries) in a dictionary:
Hunt, Richard Morris Horta, Victor, Baron Hōryū Temple
the desired result in the dictionary is:
Horta, Victor, Baron Hōryū Temple Hunt, Richard Morris
as far as the other referenced entities, I have used a stupid trick to stop the expansion. I have replaced all the ampersands with a word (like replace_me_after_transformation), and after transformation, reverse the replace back to &. that doesn't work with this situation because the word choice would place the word in a the wrong place.
thanks bill
|
|
Reply By:
|
mhkay
|
Reply Date:
|
4/21/2006 10:12:00 AM
|
Well, if you use tricks like that to stop the software behaving the way it is designed to behave, what do you expect?
Michael Kay http://www.saxonica.com/ Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
|
|
Reply By:
|
bcogney
|
Reply Date:
|
4/21/2006 10:14:06 AM
|
can you tell me of another way to make sure that entities won't be expanded in transformation
|
|
Reply By:
|
mhkay
|
Reply Date:
|
4/21/2006 10:19:04 AM
|
No, XSLT is designed so that entity references will always be expanded. This is to ensure that things like sorting work correctly!
Michael Kay http://www.saxonica.com/ Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
|
|
Reply By:
|
bcogney
|
Reply Date:
|
4/21/2006 10:49:35 AM
|
well, thanks Michael for clarifications again. do you think in future XSLT releases it would handle (or at least) give the use the option to transfer w/o expanding entities?
bill
|
|
Reply By:
|
mhkay
|
Reply Date:
|
4/21/2006 11:04:56 AM
|
I agree it's a common requirement to perform transformations that retain entity references, but it's very hard to come up with a processing model that retains them. It would greatly complicate the definition of the string data type, and of all operations on strings. It might be possible to do something that retains them as properties of the text node, so they are retained if you copy the text node (or attribute node), but are lost as soon as you atomize a text/attribute node to create a string. But that would cause a lot of user confusion as well, for example value-of would lose the entity reference while copy-of would retain it. No easy answer.
Michael Kay http://www.saxonica.com/ Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
|