ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> xsl-list
xsl-list
[xsl] ClassCastException
by other posts by this author
Dec 11 2003 11:07AM messages near this date
[xsl] HREF values in Variable | RE: [xsl] ClassCastException
why do i get the exception.....the node.xsl file is pasted below
************************************************************************************
//XML
<DATA> 
<component id="description_of_plates" type="question"> 
                <property id="label"> 
                    <value> Description of Plates:</value>
                </property> 
                <property id="help"/> 
                <property id="tooltip"/> 
                <property id="format"> 
                    <value> textbox</value>
                </property> 
                <property id="cid"> </property>
                <component id="description_of_plates" type="answer"> 
                    <property id="ans"> 
                        <value> </value>
                    </property> 
                </component> 
            </component> 

</DATA> 


************************************************************************************
//XSL
<xsl:call-template name="getvalue2"> 
	<xsl:with-param name="nodew"> 
          /DATA/component/<xsl:value-of select="$reqnode"/> 
      </xsl:with-param> 
 	<xsl:with-param name="selectid"> ans</xsl:with-param>
      <xsl:with-param name="attr"> <xsl:value-of select="."/></xsl:with-param>
</xsl:call-template> 


<xsl:template name="getvalue2" > 
        <xsl:param name="nodew"/> 
        <xsl:param name="selectid"/> 
        <xsl:param name="attr"/> 
        <xsl:value-of select="$nodew"/> 
        <xsl:call-template name="node:xpath"> 
	        <xsl:with-param name="node" > 
                <xsl:value-of select="$nodew"/> 
                </xsl:with-param> 
	  </xsl:call-template> 
</xsl:template> 
************************************************************************************


This code gives the following error

java.lang.ClassCastException; SystemID: http://127.0.0.1:9999/liberty/xsl/node.xsl; Line#: 1
7; Column#: 61 javax.xml.transform.TransformerException:j
 ava.lang.ClassCastException at org.apache.xalan.transformer.TransformerImpl.executeChildTem
plates(Unknown Source) at org.apache.xalan.templates.ElemChoose.execute(Unknown Source) at o
rg.apache.xalan.transformer.TransformerImpl.executeChildTemplates(Unknown Source) at org.apa
che.xalan.templates.ElemTemplate.execute(Unknown Source) at org.apache.xalan.templates.ElemC
allTemplate.execute(Unknown Source) at org.apache.xalan.transformer.TransformerImpl.executeC
hildTemplates(Unknown Source) at org.apache.xalan.templates.ElemTemplate.execute(Unknown Sou
rce) at org.apache.xalan.templates.ElemCallTemplate.execute(Unknown Source) at org.apache.xa
lan.transformer.TransformerImpl.executeChildTemplates(Unknown Source) at org.apache.xalan.te
mplates.ElemLiteralResult.execute(Unknown Source) at org.apache.xalan.transformer.Transforme
rImpl.executeChildTemplates(Unknown Source) at org.apache.xalan.templates.ElemLiteralResult.
execute(Unknown Source) at org.apache.xalan.transformer.TransformerIm!
 pl!
.executeChildTemplates(Unknown Source) at org.apache.xalan.templates.ElemLiteralResult.execu
te(Unknown Source) at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(Unk
nown Source) at org.apache.xalan.transformer.TransformerImpl.applyTemplateToNode(Unknown Sou
rce)


******************************************************************************
node.xsl
<?xml version="1.0"?> 

<xsl:stylesheet version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:node="http://xsltsl.org/node"
	> 



  <xsl:template name="node:xpath"> 
    <xsl:param name="node" select="."/> 

    <xsl:choose> 

      <xsl:when test="$node"> 

        <xsl:for-each select="$node[1]/ancestor-or-self::*"> 
          <xsl:text/> /<xsl:value-of select="name()"/>
          <xsl:text/> [<xsl:value-of select="count(preceding-sibling::*[name() = name(current
())]) + 1"/> ]<xsl:text/>
        </xsl:for-each> 

        <xsl:choose> 

          <xsl:when test="$node[1]/self::comment()"> 
            <xsl:text> /comment()</xsl:text>
            <xsl:text/> [<xsl:value-of select="count($node[1]/preceding-sibling::comment()) +
 1" /> ]<xsl:text/>
          </xsl:when> 

          <xsl:when test="$node[1]/self::processing-instruction()"> 
            <xsl:text> /processing-instruction()</xsl:text>
            <xsl:text/> [<xsl:value-of select="count($node[1]/preceding-sibling::processing-i
nstruction()) + 1" /> ]<xsl:text/>
          </xsl:when> 

          <xsl:when test="$node[1]/self::text()"> 
            <xsl:text> /text()</xsl:text>
            <xsl:text/> [<xsl:value-of select="count($node[1]/preceding-sibling::text()) + 1"
 /> ]<xsl:text/>
          </xsl:when> 

          <xsl:when test="not($node[1]/..)"> 
            <xsl:text> /</xsl:text>
          </xsl:when> 

          <xsl:when test="count($node[1]/../namespace::* | $node[1]) = count($node[1]/../nam
espace::*)"> 
            <xsl:text/> /namespace::<xsl:value-of select="name($node[1])" />
          </xsl:when> 

          <xsl:when test="count($node[1]/../@* | $node[1]) = count($node[1]/../@*)"> 
            <xsl:text/> /@<xsl:value-of select="name($node[1])" />
          </xsl:when> 

        </xsl:choose>       
      </xsl:when> 

      <xsl:otherwise> 
        <xsl:text> /..</xsl:text>
      </xsl:otherwise> 

    </xsl:choose> 

  </xsl:template> 



  <xsl:template name="node:type"> 
    <xsl:param name="node" select="."/> 

    <xsl:choose> 
      <xsl:when test="not($node)"/> 
      <xsl:when test="$node[1]/self::*"> 
	<xsl:text> element</xsl:text>
      </xsl:when> 
      <xsl:when test="$node[1]/self::text()"> 
	<xsl:text> text</xsl:text>
      </xsl:when> 
      <xsl:when test="$node[1]/self::comment()"> 
	<xsl:text> comment</xsl:text>
      </xsl:when> 
      <xsl:when test="$node[1]/self::processing-instruction()"> 
	<xsl:text> processing instruction</xsl:text>
      </xsl:when> 
      <xsl:when test="not($node[1]/parent::*)"> 
        <xsl:text> root</xsl:text>
      </xsl:when> 
      <xsl:when test="count($node[1] | $node[1]/../namespace::*) = count($node[1]/../namespa
ce::*)"> 
        <xsl:text> namespace</xsl:text>
      </xsl:when> 
      <xsl:when test="count($node[1] | $node[1]/../@*) = count($node[1]/../@*)"> 
        <xsl:text> attribute</xsl:text>
      </xsl:when> 
    </xsl:choose> 
  </xsl:template> 

</xsl:stylesheet> 
********************************************************************************************
********

--


MASTEK
"Making a valuable difference"
Mastek in NASSCOM's 'India Top 20' Software Service Exporters List.
In the US, we're called MAJESCO

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~
Opinions expressed in this e-mail are those of the individual and not that of Mastek Limited
, unless specifically indicated to that effect. Mastek Limited does not accept any responsib
ility or liability for it. This e-mail and attachments (if any) transmitted with it are conf
idential and/or privileged and solely for the use of the intended person or entity to which 
it is addressed. Any review, re-transmission, dissemination or other use of or taking of any
 action in reliance upon this information by persons or entities other than the intended rec
ipient is prohibited. This e-mail and its attachments have been scanned for the presence of 
computer viruses. It is the responsibility of the recipient to run the virus check on e-mail
s and attachments before opening them. If you have received this e-mail in error, kindly del
ete this e-mail from all computers.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
Thread:

Michael Kay
David Carlisle

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved