You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Gary L Peskin <ga...@firstech.com> on 2000/10/11 09:42:59 UTC

xsl:include problems

I'm having a big problem with xsl:include.  I have the XML shown below. 
The SAXParser is definitely encountering the included lxslt:component
element and building an ElemExtensionDecl for it.

However, when I examine the finished template by setting a breakpoint in
Process.java at the line (line 396) which effectively reads:

Templates stylesheet = processor.process(new InputSource(...

my ElemExtensionDecl is nowhere to be found.  Somehow the element is
being built and pushed onto a stack somewhere but the include process
must be popping that off the stack when finished processing the included
file and not placing it in the resulting template.

I'm really not familiar with this whole piece of Xalan and I've been
following ProcessorInclude and ProcessorLRE and their superclasses all
around but I'm just not there yet.  Maybe it's too late.

I thought that maybe someone familiar with this piece of code might be
able to resolve it quickly.  If there is no such person and he/she
doesn't have the time, I'll keep at it.  But if it's a relatively quick
inquiry for someone, please let me know.

Or maybe, I'm just doing something wrong and not seeing it.

Thanks,
Gary


extend04a.xsl
-------------
<?xml version="1.0"?> 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
                xmlns:lxslt="http://xml.apache.org/xslt"
                xmlns:pt="extend04.lxec1"
                extension-element-prefixes="pt">

<xsl:include href="extend04.lxecg"/>   <!-- HERE IS MY INCLUDE -->

<xsl:template match="/">
  <out>
   <xsl:text>&#010;</xsl:text>
   <xsl:choose>
     <xsl:when test="function-available('pt:xif')">function pt:xif IS
defined</xsl:when>
     <xsl:otherwise>function pt:xif IS NOT defined</xsl:otherwise>
   </xsl:choose><xsl:text>&#010;But it does work! </xsl:text>
   <xsl:value-of select="pt:xif('test')"/>

   <xsl:text>&#010;&#010;</xsl:text>
   <xsl:text></xsl:text>

   <pt:xswitch/>
   <xsl:text>&#010;</xsl:text>
   <pt:xswitch>
      <pt:case test="hello">Hello was seen</pt:case>
      <pt:case test="bye">Bye was seen</pt:case>
      <pt:default>Neither was seen</pt:default>
      <xsl:fallback>
         <xsl:text>Fallback: extension was not found.</xsl:text>
      </xsl:fallback>
   </pt:xswitch><xsl:text>&#010;</xsl:text>

   <xsl:apply-templates select="doc"/>

  </out>
</xsl:template>
 
<xsl:template match="doc">
	<xsl:for-each select="sigs">
		<xsl:call-template name="process_sigs">
			<xsl:with-param name="val" select="."/>
		</xsl:call-template>
	</xsl:for-each>
</xsl:template>

<xsl:template name="process_sigs" match="sigs">
	<xsl:param name="val">DEFAULT</xsl:param>
	<xsl:text>&#010;</xsl:text>
	<xsl:value-of select="pt:xif(string($val))"/>
</xsl:template>

</xsl:stylesheet>


extend04.lxecg
--------------
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">

<lxslt:component xmlns:lxslt="http://xml.apache.org/xslt"
                 prefix="pt" elements="xswitch" functions="xif">

<lxslt:script lang="javascript">
   <![CDATA[
      function xswitch(xslProcContext, extensionElement) 
      {
        java.lang.System.err.println ("handling 'switch' element: ");
        return new java.util.Date(0);
      }
  
      function xif(arg) 
      {
        java.lang.System.err.println ("handling 'if' element: " + arg);
	    return 'hello ' + arg +'ing';
      }
   ]]>
</lxslt:script>
</lxslt:component>

</xsl:stylesheet>