[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Generic XSL file to handle any query

Subject: Generic XSL file to handle any query
From: Gagan Kanwar <gagan_kanwar@xxxxxxxxxxxxx>
Date: 6 Apr 2000 15:03:12 -0700
gagan kanwar
Hello,

I am an XSL novice so please excuse me if this question doesn't make sense.

I have to transform queries into HTML going the XML\XSL route. The query gets represented by an XML file. The structure of this XML file is constant for now (i.e. same DTD). I can programmatically generate an XSL file that will display that XML file as a nice HTML table. So far so good. 

Is there a way that I can make just one generic XSL file that could take any XML query(assuming that they all have the same DTD) and transform that into the corresponding HTML document. 

My XML file is:
-------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<QUERY>
	<QUERY_DATA>
		<SITE_ID>1</SITE_ID>
		<DOMAIN>DOMAIN_A</DOMAIN>
		<PREFIX>IL_</PREFIX>
	</QUERY_DATA>
</QUERY>
-------------------------------------------------------

My XSL file is:
-------------------------------------------------------
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<xsl:template match="/">
	<html>
	<head>
		<title>Query Results</title>
	</head>
	<body>
	        <xsl:apply-templates select="QUERY"/>
	</body>
	</html>
</xsl:template>

<xsl:template match="QUERY">
        <h1>Query Results</h1>
	<table>
	        <th>SITE_ID</th>
	        <th>DOMAIN</th>
		<th>PREFIX</th>
	<xsl:apply-templates select="QUERY_DATA"/>
	</table>
</xsl:template>

<xsl:template match="QUERY_DATA">
	<tr>
	<td>
	        <xsl:value-of select="SITE_ID"/>
	</td>
	<td>
	        <xsl:value-of select="DOMAIN"/>
	</td>
	<td>
		<xsl:value-of select="PREFIX"/>
	</td>
	</tr>
</xsl:template>
</xsl:stylesheet>
------------------------------------------------------

In this case, each XSL file has to be customized for each XML file because element names from the XML could be different for each query. How could I write a more abstract XSL file that doesn't need to know the element names in the XML file that it transforms?

If you have made it here then I want to thank you for your perseverence.

Gagan

____________________________________________________________________

For the largest MP3 index on the Web, go to http://mp3.altavista.com

____________________________________________________________________


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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.