|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Need advise on filtering XSL
> -----Original Message-----
> From: "Stanger, Jan" <jan.stanger@xxxxxxxx>
> Sent: Tue, 28 Jan 2003 15:38:42 +0100
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Need advise on filtering XSL
>
> Hello all! This is my first post and unfortunately quite a big
> one as well. I am looking at the following XSL that has been
> written by someone else and am trying to understand certain parts
> of it. First and foremost, as you can see in the comments the
> output method has been set to text so that < and > would be treated
> properly. Elsewhere I have read that this is not a recommended way
> of creating an output XML. Also, both for-each loops in the center
> are taking very long for huge XML input documents. Is there
> anything that can be made more efficient? Since the output XML
> will be identical in structure to the input one, I thought it
> would be possible to use <xsl:copy-of select="."/> in the two
> template match functions at the bottom, but it did not work
> correctly.
Here is a stylesheet which produces what I think you want. I can't speak to the question of speed, since I don't know what your expectations are, nor do I know anything about your input file size, processor, RAM, etc.
I first had to properly close the "ColumnMetaData" elements to get a well-formed XML document. I think you will find this a simpler approach, and I'd be interested to hear if it speeds things up at all.
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:xalan="http://xml.apache.org/xalan" exclude-result-prefixes="xalan">
<xsl:strip-space elements="DataSet ResultSet ResultSetMetaData DataRow column"/>
<xsl:output method="xml" indent="yes" encoding="UTF-8" />
<xsl:param name="filterstmt" select="'ALL'"/>
<xsl:template match="/">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="DataSet">
<xsl:element name="DataSet">
<xsl:apply-templates />
</xsl:element>
</xsl:template>
<xsl:template match="ResultSetMetaData">
<xsl:element name="ResultSetMetaData">
<xsl:apply-templates />
</xsl:element>
</xsl:template>
<xsl:template match="ColumnMetaData">
<xsl:element name="ColumnMetaData">
<xsl:attribute name="dtype"><xsl:value-of select="@dtype" /></xsl:attribute>
<xsl:attribute name="name"><xsl:value-of select="@name" /></xsl:attribute>
<xsl:apply-templates />
</xsl:element>
</xsl:template>
<xsl:template match="DataRow">
<xsl:choose>
<xsl:when test="$filterstmt='ALL'">
<xsl:copy-of select="." />
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="xalan:evaluate($filterstmt)" />
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates />
</xsl:template>
<xsl:template match="node()|@*" />
</xsl:stylesheet>
--
Charles Knell
cknell@xxxxxxxxxx - email
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








