[xsl] Issue with Xalan nodeset

Subject: [xsl] Issue with Xalan nodeset
From: "Etheridge, Stephen" <stephen.etheridge@xxxxxxxxxx>
Date: Thu, 25 Nov 2010 16:33:00 +0000
Hi all

I am trying to do a transformation from Xalan in java.  I seem to be having a
nodeset() problem and need some help.  I have simplified things as follows:
I have the following simple main class.

public class doComp{
	public static void main(String[] args)
	{
		System.out.println("Hello World!");
		String infile1 = "<root>This is infile1</root>";
		String infile2 = "<root>This is infile2</root>";
		ComparatorService cs = new ComparatorService();
		String bob = cs.compareFiles(infile1,infile2);
		System.out.println(bob);

	}
}

This calls ComparatorService which works fine and sets a parameter called
secondFile

I have the following xslt:

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

<xsl:output method="text" indent="yes" />
<xsl:variable name="old_file" select="/*"></xsl:variable>
<xsl:param name="secondFile"></xsl:param>
<xsl:variable name="new_file"
select="xalan:nodeset($secondFile)/*"></xsl:variable>

	<xsl:template match="/">
		Parameter secondFile is set as
		<xsl:value-of select="$secondFile"/>
		#### Old File #####
		<xsl:value-of select="$old_file"/>
		#### New File #####
		<xsl:value-of select="$new_file"/>
		###################
	</xsl:template>
</xsl:stylesheet>


This produces the following results print out:

Hello World!

		Parameter secondFile is set as
		javax.xml.transform.dom.DOMSource@152544e
		#### Old File #####
		This is infile1
		#### New File #####

		###################

Obviously the parameter secondFile is set to a DOMSource, but the line
<xsl:variable name="new_file"
select="xalan:nodeset($secondFile)/*"></xsl:variable>
Is returning nothing.

Can anyone see what I am doing wrong?

Many thanks

Stephen


Stephen Etheridge | Managing Consultant, Information Management, Business
Optimisation Team
250 Brook Drive, Green Park, Reading RG2 6UA | United Kingdom
M: +44 7796 336 567
stephen.etheridge@xxxxxxxxxx | www.logica.com
Registered in England & Wales (registered number 947968)   
Registered Office: 250 Brook Drive, Green Park, Reading RG2 6UA, United
Kingdom


Think green - keep it on the screen.

This e-mail and any attachment is for authorised use by the intended
recipient(s) only. It may contain proprietary material, confidential
information and/or be subject to legal privilege. It should not be copied,
disclosed to, retained or used by, any other party. If you are not an intended
recipient then please promptly delete this e-mail and any attachment and all
copies and inform the sender. Thank you.

Current Thread