cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Maarten van den Dungen <maar...@shortcut.nl>
Subject processing dom node doesn't work?
Date Sun, 12 Nov 2000 19:47:37 GMT
Dear all,

I am sure that I am doing something wrong, but I can't find out what.
 From within a taglib I try to process the contents of the taglib in 
function.  In the logic part of the taglib I try to create a function 
parameter with <xsl:copy-of select="$value"/>. The idea is to be able to 
process the node in the function. I have been trying for a considerable 
time now, but somehow the java code is not properly formatted. Somhow 
normal code is generated in place of the parameter. Any suggestions 
appreciated. Thanks.

Below is an extract of the resulting code and my attempts to create the 
taglib and invoking code.

Regards,

Maarten


the resulting code ...

       func(
     xspParentNode = xspCurrentNode;
     xspNodeStack.push(xspParentNode);
     xspCurrentNode =
       document.createElement("somecontents");
     xspParentNode.appendChild(xspCurrentNode);

     xspCurrentNode.appendChild(
       document.createTextNode("\n\t\t\t\t")
     );

     xspParentNode = xspCurrentNode;
     xspNodeStack.push(xspParentNode);
     xspCurrentNode =
       document.createElement("item");
     xspParentNode.appendChild(xspCurrentNode);

     xspCurrentNode.appendChild(
       document.createTextNode("1")
     );

     ((Element) xspCurrentNode).normalize();
     xspCurrentNode = (Node) xspNodeStack.pop();

     xspCurrentNode.appendChild(
       document.createTextNode("\n\t\t\t\t")
     );

     xspParentNode = xspCurrentNode;
     xspNodeStack.push(xspParentNode);
     xspCurrentNode =
       document.createElement("item");
     xspParentNode.appendChild(xspCurrentNode);

     xspCurrentNode.appendChild(
       document.createTextNode("2")
     );

     ((Element) xspCurrentNode).normalize();
     xspCurrentNode = (Node) xspNodeStack.pop();

     xspCurrentNode.appendChild(
       document.createTextNode("\n\t\t\t")
     );

     ((Element) xspCurrentNode).normalize();
     xspCurrentNode = (Node) xspNodeStack.pop();
   );
....





the taglib:

<xsl:template match="xsp:page">
   <xsp:page>
...
     <xsp:logic>
    	  public static String func(Node node) {
// process node here...
  			return "";
         }
     </xsp:logic>
...
   </xsp:page>	
</xsl:template>

the matching template:

<xsl:template match="tryout:test">
     <xsl:variable name="value">
       <xsl:call-template name="get-nested-content">
         <xsl:with-param name="content" select="."/>
       </xsl:call-template>
     </xsl:variable>

     <xsp:logic>
	func(<xsl:copy-of select="$value"/>);
     </xsp:logic>
</xsl:template>

get nested contents like everywhere else...
<xsl:template name="get-nested-content">
   <xsl:param name="content"/>
   <xsl:choose>
     <xsl:when test="$content/*">
       <xsl:apply-templates select="$content/*"/>
     </xsl:when>
     <xsl:otherwise>"<xsl:value-of select="$content"/>"</xsl:otherwise>
   </xsl:choose>
</xsl:template>

The invoking page:

<xsp:page language="java"
	xmlns:xsp="http://www.apache.org/1999/XSP/Core"
   xmlns:tryout="http://www.itech.shortcut.nl/tryout"
   xmlns:request2="http://www.apache.org/1999/XSP/Request2"
 >
	<page>
		<tryout:test>
			<somecontents>
				<item>1</item>
				<item>2</item>
			</somecontents>	
		</tryout:test>
	</page>
</xsp:page>








Mime
View raw message