Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
|
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
 
Old April 20th, 2006, 02:34 PM
Authorized User
 
Join Date: Apr 2006
Posts: 51
Thanks: 0
Thanked 0 Times in 0 Posts
Default referenced entities

need help to order these names alphabetically
<titltxt>&Omacr;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

 
Old April 21st, 2006, 03:24 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

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

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&omacr;ry&umacr; Temple


the desired result in the dictionary is:

Horta, Victor, Baron
H&omacr;ry&umacr; 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



 
Old April 21st, 2006, 10:12 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

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

can you tell me of another way to make sure that entities won't be expanded in transformation

 
Old April 21st, 2006, 10:19 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

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

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

 
Old April 21st, 2006, 11:04 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

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





Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems with Code Referenced in Pro J! DroBuddy BOOK: Professional Joomla! ISBN: 978-0-470-13394-1 2 November 21st, 2008 12:48 AM
referenced entities bcogney XSLT 0 April 20th, 2006 02:37 PM
0x00000000 referenced memory cannot be read! otarboy Beginning VB 6 0 November 17th, 2004 02:10 AM
How do I debug an ActiveX DLL referenced by Excel? James Diamond Pro VB 6 4 July 19th, 2004 01:05 PM
Could not load referenced component: MSADODC.OCX Kendenny VB.NET 2002/2003 Basics 1 April 3rd, 2004 04:48 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.