xsl:param must be the first element within a template

Here should go questions about transforming XML with XSLT and FOP.
freemonj
Posts: 4
Joined: Mon Sep 10, 2007 10:31 pm

xsl:param must be the first element within a template

Post by freemonj »

I keep getting an error from Oxygen with the subject line above. When I look in my reference books on how to use xsl:call-templates I should be able to do the following:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ODVAcip="http://www.odva.org/schemas/ODVAcip.xsd"
version="1.0"
xml:space="preserve">
<xsl:output method="html" indent="yes" xml:space="preserve"/>


<!-- HTML layout with template call to various parsings -->
<xsl:template match="/">
<html>
<body>
<center><h1>EtherNet/IP Device Communication Report</h1></center>
<!-- <xsl:apply-templates select="//ODVAcip:ethernet_ip_device_communication_report" mode="Match_ALL" xml:space="preserve"/>-->
<xsl:call-template name="CommReport">
<xsl:with-param name="DevicePath" select="//ODVAcip:ethernet_ip_device_communication_report/device_information"/>
<xsl:with-param name="ConnectPath" select="//ODVAcip:ethernet_ip_device_communication_report/connections"/>
<xsl:with-param name="TimeConfigPath" select="//ODVAcip:ethernet_ip_device_communication_report/initialization_time_configurations"/>
<xsl:with-param name="NetworkPath" select="//ODVAcip:ethernet_ip_device_communication_report/network_services"/>
</xsl:call-template>
</body>
</html>
</xsl:template>



<xsl:template name="CommReport">
<xsl:param name="DevicePath"/>
<xsl:param name="ConnectPath"/>
<xsl:param name="TimeConfigPath"/>
<xsl:param name="NetworkPath"/>

<xsl:for-each select="$DevicePath">
<u><h2>General</h2></u>
<h3>Device Information </h3> <br/>
<b>Manufacturer</b> <u><xsl:value-of select="./ODVAcip:manufacturer"/> </u><br/>
<b>Device Name</b> <u><xsl:value-of select="./ODVAcip:product_name"/> </u><br/>
<b>Model Number</b> <u><xsl:value-of select="./ODVAcip:serial_number"/> </u><br/>
<b>Short Description</b> <u><xsl:value-of select="./ODVAcip:product_name"/> </u><br/>
<b>Firmware Version</b> <u><xsl:value-of select="./ODVAcip:major_revision"/> </u><br/>
</xsl:for-each>
....etc

Oxygen keeps complaining about xsl:param must be the first element within a template and it calls out the 4 parameter names within my template. I don't know what I am doing wrong with respect to the reference book.

Thanks,
Freemon
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

Post by george »

Hi,

The problem is that you have xml:space="preserve" and thus the whitespace before the param elements are interpreted by Saxon 6.5 as significant (as if you would have them inside xsl:text) and thus the error that Saxon 6.5 reports. Other 1.0 processors are not reporting an error in these cases being more forgiving.

To solve the problem you can very easily add an xml:space="default" in the template and then come back to xml:space="preserve" inside the for-each:

Code: Select all


<xsl:template name="CommReport" xml:space="default">
<xsl:param name="DevicePath"/>
<xsl:param name="ConnectPath"/>
<xsl:param name="TimeConfigPath"/>
<xsl:param name="NetworkPath"/>

<xsl:for-each select="$DevicePath" xml:space="preserve">
<u><h2>General</h2></u>
<h3>Device Information </h3> <br/>
<b>Manufacturer</b> <u><xsl:value-of select="./ODVAcip:manufacturer"/> </u><br/>
<b>Device Name</b> <u><xsl:value-of select="./ODVAcip:product_name"/> </u><br/>
<b>Model Number</b> <u><xsl:value-of select="./ODVAcip:serial_number"/> </u><br/>
<b>Short Description</b> <u><xsl:value-of select="./ODVAcip:product_name"/> </u><br/>
<b>Firmware Version</b> <u><xsl:value-of select="./ODVAcip:major_revision"/> </u><br/>
</xsl:for-each>
</xsl:template>
Best Regards,
George
George Cristian Bina
Post Reply