A Dynamic XSL Transformation
page 1 of 4
Published: 02 Sep 2004
Unedited - Community Contributed
Abstract
What do you do when you need to transform an XML file but will not know the exact structure of the XML file? This article will demonstrate a method for performing a transformation on an XML where the nodes of the document could vary.
by Michelle Beall
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 24115/ 33

Introduction

A project I was involved in required me to generate a HTML table from an XML file.  Simple enough, right?  The transformation would be easy; for each node create a new table row and each attribute would be a table cell.  This would be a nice project to get introduced to XML and XSL.

The catch was that although the XML nodes were defined, the attribute names could vary from one time to the next.  The column title had to reflect the dynamic attribute names and the HTML table had to be displayed in a certain format.  So the challenge came when trying to figure out how to create the XSL and display empty cells when an attribute was not present, especially when I would not know the attribute name until runtime.

The XML is generated by a Sharepoint Web Service.  The attribute names are names of custom fields created by the user in a Sharepoint Document Library.  Sharepoint's list web service returns some standard attributes by default, those would always be known, as well as any columns specified by the query.

Hopefully this article will give you some ideas as to how to approach similar or more complicated XSL challenges.

The following was used in generating the example:

  • Microsoft Visual Studio .NET 2003 (1.1 Framework)
  • Microsoft Visual C#
  • Web service running on IIS 5
  • XML
  • XSL

 


View Entire Article

User Comments

No comments posted yet.






Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-04-19 4:15:54 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search