Subject: [xsl] testing for variable amounts of whitespace? From: bill french <bill@xxxxxxxxxxxxxxxx> Date: Fri, 27 Apr 2001 14:02:40 -0400 |
hi all, first - the problem: i'm building an xml doc from a database. some of the fields contain variable amounts of whitespace. whenever my stylesheet comes across a node containing only whitespace, i'd like to turn it all into one html non-breaking space entity ( ). (i'm already stripping whitespace from nodes whose values aren't whitespace-only with the normalize-space() function.) second - the questions: can i write an xpath expression to test for a variable amount of whitespace? how would i do such a thing? third - the relevent info: parser: MSXML 3 working in conjunction with microsoft's xslisapi dll for IIS. i'm pretty new to all of this; please forgive my ignorance. thanks, --bill ahh yes, the xml: <?xml version="1.0" ?> <?xml-stylesheet type="text/xsl" server-config="sampleconfig.xml" ?> <employees> <employee id="100" status="A"> <firstName>George </firstName> <middleName> </middleName> <lastName>Bush </lastName> <emailAddress>george@xxxxxxxxxxxxxx </emailAddress> <homePhone>202-456-9999 </homePhone> <mobilePhone> </mobilePhone> <address id="1"/> </employee> </employees> --- and the stylesheet: <?xml version="1.0" ?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" > <xsl:template match="/"> <html> <head> <style> .sans {font-family:verdana; font-size:12px;} .sansBigger {font-family:verdana; font-size:14px;} </style> <title>example two - using xsl:apply-templates</title> </head> <body bgcolor="#ff9400" text="#ffff33"> <table bgcolor="#ffff33" border="0" cellpadding="0" cellspacing="0"> <tr> <td><table border="0" bgcolor="#ff9400" cellpadding="8" cellspacing="1"> <tr bgcolor="#f58000"> <td class="sansBigger" nowrap="nowrap"><b class="sansBigger" >first name</b></td> <td class="sansBigger" nowrap="nowrap"><b>middle name</b></td> <td class="sansBigger" nowrap="nowrap"><b>last name</b></td> <td class="sansBigger" nowrap="nowrap"><b>email address</b></td> <td class="sansBigger" nowrap="nowrap"><b>home phone</b></td> <td class="sansBigger" nowrap="nowrap"><b>mobile phone</b></td> </tr> <xsl:apply-templates select="nsEmployees/employee"> <xsl:sort select="lastName" /> </xsl:apply-templates> </table></td> </tr> </table> </body> </html> </xsl:template> <xsl:template match="employee"> <xsl:if test="@status = 'A'"> <tr> <xsl:apply-templates select="firstName" /> <xsl:apply-templates select="middleName" /> <xsl:apply-templates select="lastName" /> <xsl:apply-templates select="emailAddress" /> <xsl:apply-templates select="homePhone" /> <xsl:apply-templates select="mobilePhone" /> </tr> </xsl:if> </xsl:template> <xsl:template match="firstName"> <td class="sans"> <xsl:if test=""> </xsl:if> <xsl:value-of select="normalize-space()" /></td> </xsl:template> <xsl:template match="middleName"> <td class="sans"><xsl:value-of select="normalize-space()" /></td> </xsl:template> <xsl:template match="lastName"> <td class="sans"><xsl:value-of select="normalize-space()" /></td> </xsl:template> <xsl:template match="emailAddress"> <td class="sans"><xsl:value-of select="normalize-space()" /></td> </xsl:template> <xsl:template match="homePhone"> <td class="sans"><xsl:value-of select="normalize-space()" /></td> </xsl:template> <xsl:template match="mobilePhone"> <td class="sans"><xsl:value-of select="normalize-space()" /></td> </xsl:template> </xsl:stylesheet> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] using xalan extension lib - r, Jih, Felix | Thread | Re: [xsl] testing for variable amou, bill french |
Re: [xsl] xsl] XSL and XMLSchema wi, Edward Kennedy | Date | Re: [xsl] xsl] XSL and XMLSchema wi, Eric van der Vlist |
Month |