RE: [xsl] MSXML 4 - RowSetSchema XML

Subject: RE: [xsl] MSXML 4 - RowSetSchema XML
From: "Kirk Allen Evans" <kaevans@xxxxxxxxxxxxx>
Date: Sat, 7 Feb 2004 22:02:08 -0500
> Q: How do I write the XSL to detect a missing rowset attribute? I want 
> to add whitespace to the cell to keep the data set lined up in the correct
> columns.

One way is to test to see if the element has all of the attributes by
specifying them in the XSLT:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>	
	<xsl:output method="text"/>	
	<xsl:template match="root">		
		<xsl:text>
Nodes without A:
		</xsl:text>		
		<xsl:apply-templates select="child::*[not(@a)]"/>

		<xsl:text>
Nodes without B:
		</xsl:text>		
		<xsl:apply-templates select="child::*[not(@b)]"/>

		<xsl:text>
Nodes without C:
		</xsl:text>		
		<xsl:apply-templates select="child::*[not(@c)]"/>	
	</xsl:template>	
	<xsl:template match="*">		
		<xsl:value-of select="local-name()"/>		
		<xsl:if test="position() != last()">			
			<xsl:text>,</xsl:text>		
		</xsl:if>	
	</xsl:template>
</xsl:stylesheet>

Given the input document:
<root>	
	<foo a="1" b="2" c="3"/>
	<bar a="1"/>	
	<baz a="1" b="2"/>		
</root>

The result is:


Nodes without A:
		
Nodes without B:
		bar
Nodes without C:
		bar,baz


This may fit your scenario because you specified you were using ADO and the
RowSetSchema [1], where you will always have a fixed number of attributes
for each of the s:AttributeType elements.  This approach does not work well
for the child s:DataType element, where the number of attributes is
determined by the datatype itself (a type of "int" will have an
"rs:precision" attribute, while a type of "string" will not).  

This approach is not very reusable in different instances because you rely
on the same attributes to be present for each element.  You could just take
the approach of finding out the maximum number of attributes [2] that an
element may have and use that when generating the table.

[1] http://gethelp.devx.com/techtips/xml_pro/10min/10min0100/listing2.htm

[2] http://www.topxml.com/code/default.asp?p=3&id=v20030314165921



-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of
tbstewart@xxxxxxx
Sent: Friday, February 06, 2004 8:05 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: [xsl] MSXML 4 - RowSetSchema XML

Hi,

I am using MSXML 4.0 to perform server-side (memory resident)
transformations in my Classic ASP Web application. The default XML that
ADO generates is a combination of the schema and the XML in what MS calls
a RowSetSchema. The problem with using the XML as is, is that when a data
item is null the node's attribute is not included in the rowset. Hence,
the report's table cell is not preserved and the remaining data columns
shift one or more columns to the left.

Q: How do I write the XSL to detect a missing rowset attribute? I want to
add whitespace to the cell to keep the data set lined up in the correct
columns.

Thanks for your help.

Cheers,
--Tom



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



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


Current Thread