Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Client-side XSL Transformations 1

Status
Not open for further replies.

mesagreg

Programmer
Mar 3, 2001
53
US
Hi Gang,

I have a desktop application that uses xml for reporting and xslt to generate html reports. I am using the <xsl:param> tag in my xsl file to specify input parameters. In my app, I simply want to pass a URL to a web browser like:

file///c:\somedata.xml?ID=1

and have the stylesheet process the request based on the input parameter.

Can I do this client side without a server?

Thanks,

Greg
 
Only if your clients have msxml3 installed in replace mode or run Internet Explorer 6.0.

Older versions of Internet explorer don't support the xsl:param element as child of the xsl:stylesheet element.

Jordi Reineman
 
I have both MSXML3 and IE 6 running on my development machine, but I can't figure out how to pass the parameter in correctly. I am setting a default value for the parameter in the xsl file, and the query runs perfectly. When I pass in a new parameter, the query results don't change, and when I remove the default value in the xsl file the query fails altogether.

Following are abbreviated snippets from my xml and xsl files:
=======================================================
XML

<?xml version=&quot;1.0&quot; ?>
<?xml-stylesheet type=&quot;text/xsl&quot; href=&quot;c:\invoice.xsl&quot;?>
<TVAIM>
<Batch>
<BatchNumber>1</BatchNumber>
<BatchDate>11/07/2001</BatchDate>
<Invoice BatchNumber=&quot;1&quot; ID=&quot;1&quot;>
<BeginningDate>12:00:00 AM</BeginningDate>
<ContractNumber></ContractNumber>
<CostClassification></CostClassification>
<CostCode></CostCode>
<EmployeeInit></EmployeeInit>
<EndingDate>12:00:00 AM</EndingDate>
<ExportFileLocation></ExportFileLocation>
<HTMLFileLocation></HTMLFileLocation>
<InvoiceAmount>0</InvoiceAmount>
<InvoiceNumber>122</InvoiceNumber>
<InvoiceType></InvoiceType>
<Location></Location>
<PerformingUnit></PerformingUnit>
<RDNumber></RDNumber>
<TVAShortCode></TVAShortCode>
<VendorNumber></VendorNumber>
<TaskNumber></TaskNumber>
</Invoice>

XSL

<xsl:stylesheet version='1.0' xmlns:xsl='<xsl:param name=&quot;InvoiceID&quot;>1</xsl:param>
<xsl:template match=&quot;/&quot;>
<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>
<xsl:for-each select=&quot;TVAIM/Batch&quot;>
<xsl:apply-templates select=&quot;Invoice[@ID=@InvoiceNumber]&quot;></xsl:apply-templates>
</xsl:for-each>

<xsl:template match=&quot;Invoice&quot;>
<TABLE align=&quot;center&quot; border=&quot;1&quot; cellPadding=&quot;0&quot; cellSpacing=&quot;1&quot; width=&quot;480&quot; id=&quot;TABLE1&quot; borderColor=&quot;silver&quot;>
<TR>
<TD align=&quot;left&quot;><STRONG><FONT face=&quot;Tahoma&quot;>Invoice Number</FONT> </STRONG> </TD>
<TD align=&quot;left&quot;><FONT face=&quot;Tahoma&quot;><xsl:value-of select=&quot;InvoiceNumber&quot; /></FONT></TD></TR>
</xsl:template>
</xsl:stylesheet>
=====================================================

Any suggestions on how I can make this thing work?

Thanks,

Greg
 
I assume you call your xml like this:
myxmlFile.xml?InvoiceID=2

Does your code change correctly if you change your default value?
 
Yes. That is how I make the call in my browser. And the correct item is rendered in the browser when the default value changes.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top