[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Looking Not Working for No Obvious Reason

Subject: Re: Looking Not Working for No Obvious Reason
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 20 Jun 2007 19:35:10 +0100
Re:  Looking Not Working for No Obvious Reason
> I must be doing something wrong but I can't figure out what it might 
> be--the fact that some input values work and others don't is odd.

usual cause of cause is user error, strings that look the same but
aren't due to white space or whatever. Can you post an actual example
that fails to match?

> The real mapping is small enough I could rewrite the code to use 
> choose/when for the mappings but this seemed like the most efficient way 
> to do a two-way mapping in XSLT.

Normaly I'd use a key for such lookups, which ought to be more efficient
(or as efficient if   your optimizing xslt engine decided to make an
internal key anyway)

<xsl:key name="x" match="item" use="shorttitle"/>

Then

   <xsl:function
     name="func:getShortTitleForSection" as="xs:string">
     <xsl:param
       as="xs:string"
       name="sectionBaseTitle"/>
  <xsl:sequence
     select="key('x',$sectionBaseTitle,$sectionTitleMap),$sectionBaseTitle)[1]"/>
   </xsl:function>


(which isn't quite the same as if you have two titles with teh same
short name this will use the first long name, whereas you's would use
the short name, but that could be fixed but I assume it doesn't happen
anyway in a static mapping built into the stylesheet.

as="document-node()">
     <xsl:document>

those two bits aren't needed (but perhaps documenting them is good form)
as the default behaviour is to implictly make a document node (for xslt
1 compat, mainly) or maybe that's the cause of your lookup failures,
perhaps sometimes you have got duplicated short titles?

David


________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. 
________________________________________________________________________

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.