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

how to get string value of element node without childr

Subject: how to get string value of element node without children concatenated
From: "Craig Kattner" <CKattner@xxxxxxxxxxxxxx>
Date: Fri, 14 Mar 2003 14:29:35 -0600
get string
I'm sure the answer is obvious, but I can't seem to find it.

I have the following XML:
<?xml version="1.0" encoding="UTF-8" ?> 
<switches>
	<finishes>
		<finish>
			Almond Decorative 
			<hold>no</hold> 
		</finish>
		<finish>
			Commercial 
			<hold>no</hold> 
			<hold>yes</hold> 
		</finish>
		<finish>
			Ivory Decorative 
			<hold>no</hold> 
			<hold>yes</hold> 
		</finish>
		<finish>
			White Decorative 
			<hold>no</hold> 
		</finish>
	</finishes>
</switches>

And this stylesheet:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="UTF-8" />

<xsl:template match="/">
	<table border="1" cellspacing="0" cellpadding="0" cols="{count(//hold)+1}">
		<tr class="finish">
			<th rowspan="2">Time Cycle</th>
			<xsl:apply-templates select="/switches/finishes" />
		</tr>
		<tr class="hold">
			<xsl:apply-templates select="/switches/finishes/finish" mode="hold" />
		</tr>
	</table>
</xsl:template>

<xsl:template match="finishes">
	<xsl:for-each select="finish">
		<th colspan="{count(descendant::hold)}">
			<xsl:value-of select="." />
		</th>
	</xsl:for-each>
</xsl:template>

<xsl:template match="finish" mode="hold">
	<xsl:for-each select="hold">
		<th>
			<xsl:value-of select="current()" />
		</th>
	</xsl:for-each>
</xsl:template>

</xsl:stylesheet>

Which produces the following output:
<table border="1" cellspacing="0" cellpadding="0" cols="7">
	<tr class="finish">
		<th rowspan="2">Time Cycle</th> 
		<th colspan="1">Almond Decorativeno</th> 
		<th colspan="2">Commercialnoyes</th> 
		<th colspan="2">Ivory Decorativenoyes</th> 
		<th colspan="1">White Decorativeno</th> 
	</tr>
	<tr class="hold">
		<th>no</th> 
		<th>no</th> 
		<th>yes</th> 
		<th>no</th> 
		<th>yes</th> 
		<th>no</th> 
	</tr>
</table>

That's the correct output (according to Michael Kay's 2nd edition the string value of an element is the string value of the element and all it's children concatenated). But I need to get the string value WITHOUT the concatenation. IE I want my output to look like:
<table border="1" cellspacing="0" cellpadding="0" cols="7">
	<tr class="finish">
		<th rowspan="2">Time Cycle</th> 
		<th colspan="1">Almond Decorative</th> 
		<th colspan="2">Commercial</th> 
		<th colspan="2">Ivory Decorative</th> 
		<th colspan="1">White Decorative</th> 
	</tr>
	<tr class="hold">
		<th>no</th> 
		<th>no</th> 
		<th>yes</th> 
		<th>no</th> 
		<th>yes</th> 
		<th>no</th> 
	</tr>
</table>

I'm having exactly zero luck on this one though. Using MSXML 4.0 SP 1 for this.

Craig


 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.