xsl-list
[Top] [All Lists]

Re: [xsl] Looking Not Working for No Obvious Reason

2007-06-20 13:55:04

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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--