[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 21:53:35 +0100
Re:  Looking Not Working for No Obvious Reason
> Input data is:..
saved as ek.xml

> The corresponding mapping entry is:
I commented out that entry from your original post and replaced it with
that (just in case there was a weird difference somewhere), and the
function you posted worked for me, see below.

failing user error, other possibility is system bug, I'm using
Saxon 8.9J from Saxonica
ie the latest full release of the basic processor, not a later version
from subversion for example.

ek.xml

<title>Overview and Background</title>

ek.xsl

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema"
		xmlns:func="data:,f">
     <xsl:variable name="sectionTitleMap" as="document-node()">
     <xsl:document>
     <map>
<item>
   <shorttitle>Background</shorttitle>
   <longtitle>Overview and Background</longtitle>
</item>
<!--       <item>
         <shorttitle>Background</shorttitle>
         <longtitle>Overview and Background</longtitle>
       </item>
-->
       <item>
         <shorttitle>Scope</shorttitle>
         <longtitle>Scope and Scope Exceptions</longtitle>
       </item>
       <item>
         <shorttitle>Glossary</shorttitle>
         <longtitle>Topical Definitions - Glossary</longtitle>
       </item>
      </map>
    </xsl:document>
     </xsl:variable>

<!--I then have this function to do lookups:-->

   <xsl:function
     name="func:getShortTitleForSection" as="xs:string">
     <xsl:param
       as="xs:string"
       name="sectionBaseTitle"/>
     <xsl:choose>
       <xsl:when test="count($sectionTitleMap//longtitle[. = 
$sectionBaseTitle]) = 1">
         <xsl:sequence select="$sectionTitleMap//item[longtitle[. = 
$sectionBaseTitle]]/shorttitle"/>
       </xsl:when>
       <xsl:otherwise>
         <xsl:sequence select="$sectionBaseTitle"/>
       </xsl:otherwise>
     </xsl:choose>

   </xsl:function>


<xsl:template match="title">
 Title: <xsl:value-of select="func:getShortTitleForSection(.)"/>
</xsl:template>

</xsl:stylesheet>



$ saxon8 ek.xml ek.xsl
<?xml version="1.0" encoding="UTF-8"?>
 Title: Background

________________________________________________________________________
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.