[xsl] Passing params to XSLT from Java - Exception

Subject: [xsl] Passing params to XSLT from Java - Exception
From: jm0019@xxxxxxxxxxxxxxxxxx
Date: Wed, 4 Dec 2002 12:06:01 +0000
Hello,

I am trying to pass params to a xsl stylesheet from a Java application.  It 
falls over with the following error

"org.xml.sax.SAXParseException: Content is not allowed in prolog." and it 
seems as if this is caused by the parameters. I have included both the xslt 
and java code snippet.  Any suggestions are most welcome.

Thanks
Julie.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; 
xmlns:fo="http://www.w3.org/1999/XSL/Format";>
	
<xsl:output method="html" indent="yes" omit-xml-declaration="no" 
version="1.0"/>	
	<xsl:param name="highPref"/>
	<xsl:param name="medPref"/>
	<xsl:param name="lowPref"/>	

	<xsl:template match="/">
		<html>
			<head>
				<title></title>
			</head>
			<body>
				<xsl:variable name="cats" 
select="InfoStreamResults/Article/Categories/Category[.=$highPref 
or .=$medPref or .=$lowPref]"/>
				<xsl:variable name="articles">
					<xsl:for-each select="$cats">
						<xsl:value-of 
select="./../.."/>
					</xsl:for-each>			
	
				</xsl:variable>

				<xsl:variable name="art" select="$cats/../.."/>
				<xsl:for-each select="$art[@ID != 
preceding::Article/@ID]">
					<xsl:variable name="relativeUrl">
						<xsl:value-of 
select="'newsStory.xml?'"/>
					</xsl:variable>
				
					<xsl:variable name="heading">
						<xsl:value-of 
select="Heading"/>			
					</xsl:variable>
					
					<xsl:variable name="articleId">
						<xsl:value-of select="concat
('articleId=',@ID)"/>
					</xsl:variable>
					
					<xsl:variable name="categoryId">
						<xsl:for-each 
select="Categories/Category">
							<xsl:value-of 
select="concat('&amp;categoryId', position(), '=', @ID)"/>
						</xsl:for-each>
					</xsl:variable>			
					
					<a href="{$relativeUrl}{$articleId}
{$categoryId}">
						<xsl:value-of 
select="$heading"/>
					</a>
					<br />
		
				</xsl:for-each>
			</body>
		</html>
	</xsl:template>

</xsl:stylesheet>


Writer transformedXml = new StringWriter();
Reader sourceXml = new StringReader(xml);        
Transformer transformer = tFactory.newTransformer(new StreamSource
(urlXslt));    
transformer.setParameter("highPref", user.getHighPref());
transformer.setParameter("medPref", user.getMedPref());
transformer.setParameter("lowPref", user.getLowPref());
transformer.transform(new StreamSource(sourceXml),new StreamResult
(transformedXml));  // line exception thrown from




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


Current Thread