 |
| XML General XML discussions. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

April 20th, 2006, 02:34 PM
|
|
Authorized User
|
|
Join Date: Apr 2006
Posts: 51
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
referenced entities
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
|
|

April 21st, 2006, 03:24 AM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
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
|
|

April 21st, 2006, 09:55 AM
|
|
Authorized User
|
|
Join Date: Apr 2006
Posts: 51
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

April 21st, 2006, 10:12 AM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
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
|
|

April 21st, 2006, 10:14 AM
|
|
Authorized User
|
|
Join Date: Apr 2006
Posts: 51
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
can you tell me of another way to make sure that entities won't be expanded in transformation
|
|

April 21st, 2006, 10:19 AM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
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
|
|

April 21st, 2006, 10:49 AM
|
|
Authorized User
|
|
Join Date: Apr 2006
Posts: 51
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

April 21st, 2006, 11:04 AM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
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
|
|
 |