You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by Rashmi Rubdi <de...@yahoo.com> on 2006/08/02 17:07:40 UTC

Is it possible to read a value generated from within an XSL file into a JSP?

Hello, 
   
  I am trying to read a value that is generated inside an XSLT file (session_test.xsl ) , in to the  JSP file (session_test.jsp) that contains the code to transform the  XML (session_test.xml)
   
  I want to store the value of sub-node , and the value of the generated id as session parameters inside the JSP file. 
   
  Is there a way to read a value generated inside an XSL into the JSP ?
   
  session_test.xml
   
  <?xml version="1.0" encoding="UTF-8"?>
<root-node>
<some-nodes>
    <node>
        <sub-node>some_value_1</sub-node>
    </node>
    <node>
        <sub-node>some_value_2</sub-node>
    </node>
    <node>
        <sub-node>some_value_3</sub-node>
    </node>
    <node>
        <sub-node>some_value_4</sub-node>
    </node>
</some-nodes>
</root-node>
  -----------------------------
  session_test.xsl
   
  <?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output omit-xml-declaration="yes"/>
    <xsl:template match="/">
        <xsl:for-each select="root-node/some-nodes/node">
            <xsl:value-of select="sub-node"/>
            <br/>
            <xsl:value-of select="generate-id()"/>
            <hr/>
        </xsl:for-each>
    </xsl:template>
</xsl:stylesheet>
  ----------------------------------
  session_test.jsp
   
  <%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml" %>
<html>
  <head><title></title></head>
  <body>
      <c:import url="session_test.xml" var="xml" charEncoding="UTF-8"/>
    <c:import url="session_test.xsl" var="xsl" charEncoding="UTF-8"/>
    <x:transform doc="${xml}" xslt="${xsl}"/>
  </body>
</html>
   
  -Thank you
   

 __________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Re: Is it possible to read a value generated from within an XSL file into a JSP?

Posted by Kris Schneider <kr...@dotech.com>.
Glad it helped - everyone's a newbie at some point...

Quoting Rashmi Rubdi <de...@yahoo.com>:

> Yes, this definitely helps I am now able to get additional information from
> the intermediate xslt transformation. 
>    
>   Sorry, if my question was inane, I'm a newbie to JSTL and I was looking for
> a way to do 2 xslt transformations, didn't know it was this easy.
>    
>   Thank you very much.
> 
> Kris Schneider <kr...@dotech.com> wrote:
>   If you store the result of your transform in a var:
> 
> 
> 
> Then you can use / with an XPath expression to grab what you need.
> Will that help or have I misunderstood what you're trying to do?
> 
> Quoting Rashmi Rubdi :
> 
> > Hello, 
> > 
> > I am trying to read a value that is generated inside an XSLT file
> > (session_test.xsl ) , in to the JSP file (session_test.jsp) that contains
> > the code to transform the XML (session_test.xml)
> > 
> > I want to store the value of sub-node , and the value of the generated id
> > as session parameters inside the JSP file. 
> > 
> > Is there a way to read a value generated inside an XSL into the JSP ?
> > 
> > session_test.xml
> > 
> > 
> > 
> > 
> > 
> > some_value_1
> > 
> > 
> > some_value_2
> > 
> > 
> > some_value_3
> > 
> > 
> > some_value_4
> > 
> > 
> > 
> > -----------------------------
> > session_test.xsl
> > 
> > 
> > > xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> > 
> > 
> > 
> > 
> > 
> 
> > 
> >   
> ---------------------------------
>   
> > 
> > 
> > 
> > ----------------------------------
> > session_test.jsp
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > -Thank you
> 
> -- 
> Kris Schneider 
> D.O.Tech 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
> 
> 
> 
>  __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 


-- 
Kris Schneider <ma...@dotech.com>
D.O.Tech       <http://www.dotech.com/>

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: Is it possible to read a value generated from within an XSL file into a JSP?

Posted by Rashmi Rubdi <de...@yahoo.com>.
Yes, this definitely helps I am now able to get additional information from the intermediate xslt transformation. 
   
  Sorry, if my question was inane, I'm a newbie to JSTL and I was looking for a way to do 2 xslt transformations, didn't know it was this easy.
   
  Thank you very much.

Kris Schneider <kr...@dotech.com> wrote:
  If you store the result of your transform in a var:



Then you can use / with an XPath expression to grab what you need.
Will that help or have I misunderstood what you're trying to do?

Quoting Rashmi Rubdi :

> Hello, 
> 
> I am trying to read a value that is generated inside an XSLT file
> (session_test.xsl ) , in to the JSP file (session_test.jsp) that contains
> the code to transform the XML (session_test.xml)
> 
> I want to store the value of sub-node , and the value of the generated id
> as session parameters inside the JSP file. 
> 
> Is there a way to read a value generated inside an XSL into the JSP ?
> 
> session_test.xml
> 
> 
> 
> 
> 
> some_value_1
> 
> 
> some_value_2
> 
> 
> some_value_3
> 
> 
> some_value_4
> 
> 
> 
> -----------------------------
> session_test.xsl
> 
> 
> > xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> 
> 
> 
> 
> 

> 
>   
---------------------------------
  
> 
> 
> 
> ----------------------------------
> session_test.jsp
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> -Thank you

-- 
Kris Schneider 
D.O.Tech 

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org



 __________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Re: Is it possible to read a value generated from within an XSL file into a JSP?

Posted by Kris Schneider <kr...@dotech.com>.
If you store the result of your transform in a var:

<x:transform var="transformed" doc="${xml}" xslt="${xsl}"/>

Then you can use <x:set>/<x:out> with an XPath expression to grab what you need.
Will that help or have I misunderstood what you're trying to do?

Quoting Rashmi Rubdi <de...@yahoo.com>:

> Hello, 
>    
>   I am trying to read a value that is generated inside an XSLT file
> (session_test.xsl ) , in to the  JSP file (session_test.jsp) that contains
> the code to transform the  XML (session_test.xml)
>    
>   I want to store the value of sub-node , and the value of the generated id
> as session parameters inside the JSP file. 
>    
>   Is there a way to read a value generated inside an XSL into the JSP ?
>    
>   session_test.xml
>    
>   <?xml version="1.0" encoding="UTF-8"?>
> <root-node>
> <some-nodes>
>     <node>
>         <sub-node>some_value_1</sub-node>
>     </node>
>     <node>
>         <sub-node>some_value_2</sub-node>
>     </node>
>     <node>
>         <sub-node>some_value_3</sub-node>
>     </node>
>     <node>
>         <sub-node>some_value_4</sub-node>
>     </node>
> </some-nodes>
> </root-node>
>   -----------------------------
>   session_test.xsl
>    
>   <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>     <xsl:output omit-xml-declaration="yes"/>
>     <xsl:template match="/">
>         <xsl:for-each select="root-node/some-nodes/node">
>             <xsl:value-of select="sub-node"/>
>             <br/>
>             <xsl:value-of select="generate-id()"/>
>             <hr/>
>         </xsl:for-each>
>     </xsl:template>
> </xsl:stylesheet>
>   ----------------------------------
>   session_test.jsp
>    
>   <%@ page contentType="text/html;charset=UTF-8" language="java" %>
> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
> <%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml" %>
> <html>
>   <head><title></title></head>
>   <body>
>       <c:import url="session_test.xml" var="xml" charEncoding="UTF-8"/>
>     <c:import url="session_test.xsl" var="xsl" charEncoding="UTF-8"/>
>     <x:transform doc="${xml}" xslt="${xsl}"/>
>   </body>
> </html>
>    
>   -Thank you

-- 
Kris Schneider <ma...@dotech.com>
D.O.Tech       <http://www.dotech.com/>

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org