users
[Top] [All Lists]

RE: [cinjug-users] WSAD5 and xalan questions

To: "Wu, Xiang (LNG-DAY)" <xiang.wu@xxxxxxxxxxxxxx>, <users@xxxxxxxxxx>
Subject: RE: [cinjug-users] WSAD5 and xalan questions
From: "Herbers, Joe" <joe.herbers@xxxxxxx>
Date: Tue, 17 Jun 2003 13:39:16 -0400
Delivered-to: mailing list users@cinjug.org
Mailing-list: contact users-help@cinjug.org; run by ezmlm
Thread-index: AcM07U3hlSx5GaDfEdeOuACgyZkotgACNWUw
Thread-topic: [cinjug-users] WSAD5 and xalan questions
T get an app that required a newer version of Xalan to run on WAS 4, I had to 
drop xalan.jar in AppServer\lib\app  I believe this is where their docs say you 
should put such jars (they even give xalan as an example)

AppServer\classes also works, and that's what I ended up using because on a 
trial version of WAS4, putting xalan.jar in lib\app caused problems when I ran 
the WAS console.  I think you're also supposed to be able to drop jars in 
lib\ext but I don't recall that working for me.


-----Original Message-----
From: Wu, Xiang (LNG-DAY) [mailto:xiang.wu@xxxxxxxxxxxxxx]
Sent: Tuesday, June 17, 2003 12:26 PM
To: users@xxxxxxxxxx
Subject: [cinjug-users] WSAD5 and xalan questions

Hi,
I am using WSAD5 to write a xsl stylesheet that is using xalan extension
function "xalan:nodeset". it runs correctly under "Websphere v5.0 test
environment" and IDE environment, but gets an unexpected result under
"Websphere v4.0 test environment" (I attached the xml, xsl, jsp and result
files below). I notice that these two test environments use different
versions of XALAN (1.2.2 for v4 and 2.3.4 for v5). It seems that XALAN 1.2.2
confuses with "child" and "descendant" once "xalan:nodeset" is used.  My
questions are:
1. Did anyone have this problem before?  Is there any work-around if we need
to keep using the old version of XALAN?
2. How to upgrade XALAN to the newer version for WAS v4 test environment. I
tried to add jar files to "ws.ext.dirs" in server configuration, but it is
still not working.  

Thanks in advance.

Xiang Wu

xml file:
<?xml version="1.0" encoding="UTF-8"?>
<test>
  <person>
    <first>J<font color="red">oh</font>n</first>
    <last>Doe</last>
  </person>
</test>



xsl file:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
    version="1.0"
    xmlns:xalan="http://xml.apache.org/xalan";
    exclude-result-prefixes="xalan"
>


<xsl:template match="/">
<html>
  <body>
    <xsl:variable name="name">
      <xsl:apply-templates select="/test/person/last"/>
      <xsl:apply-templates select="/test/person/first"/>
    </xsl:variable>
    <p>
      <xsl:call-template
name="listToTextSeperatedByDelimiterWithoutWrapperElement">
        <xsl:with-param name="list" select="xalan:nodeset($name)/*"/>
        <xsl:with-param name="delimiter" select="','"/>
      </xsl:call-template>
    </p>
  </body>
</html>
</xsl:template>
    
    
<!-- convert a list of element into a text (inheriting all child elements)
-->
<xsl:template name="listToTextSeperatedByDelimiterWithoutWrapperElement">
  <xsl:param name="list"/>
  <xsl:param name="delimiter"/>
   
  <xsl:for-each select="$list[normalize-space(.)]">
    <xsl:apply-templates/>
    <xsl:choose>
      <xsl:when test="position() = last()"/>   <!-- do nothing -->
      <xsl:otherwise>
        <xsl:value-of select="concat(normalize-space($delimiter), ' ')"/> 
      </xsl:otherwise>
    </xsl:choose>
  </xsl:for-each>
</xsl:template>




<!-- deep copy -->
<xsl:template match="*">
  <xsl:copy>
    <xsl:copy-of select="@*"/>
    <xsl:apply-templates />
  </xsl:copy>
</xsl:template>
    
</xsl:stylesheet>


Jsp file:
<%@ page import="java.io.File" %>
<%@ page import="javax.xml.transform.TransformerFactory" %>
<%@ page import="javax.xml.transform.Transformer" %>
<%@ page import="javax.xml.transform.stream.StreamSource" %>
<%@ page import="javax.xml.transform.stream.StreamResult" %>


<%
    File xmlFile = new File("testcopy.xml");
    File xslFile = new File("testcopy_nodeset.xsl"); 
    
    try {
            //Get the transformer
        TransformerFactory tFactory = TransformerFactory.newInstance();
        Transformer transformer = tFactory.newTransformer (new
StreamSource(xslFile));
        transformer.transform ( new StreamSource(xmlFile), new
StreamResult(response.getWriter())  );
    } catch (Exception ex) {
        ex.printStackTrace();
        throw new ServletException(ex);
    }
            
%>



result in WAS v4 test env
<html>
<body>
<p>Doe, J<font color="red">oh</font>n, oh</p>
</body>
</html>


result in WAS v5 test env
<html>
<body>
<p>Doe, J<font color="red">oh</font>n</p>
</body>
</html>

<Prev in Thread] Current Thread [Next in Thread>
  • RE: [cinjug-users] WSAD5 and xalan questions, Herbers, Joe <=