Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] XSLT test condition

From: Senthilukvelaan <skumaravelan@-------------->
To:
Date: 3/2/2009 11:13:00 PM
I use the below XSLT and When I content-type has the same value in
text/html and it goes to the
otherwise condition.  I am not sure how do I escape the "/" during the test.
Any pointers would be helpful.
Thanks,
Sen
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
	<xsl:variable name="HTML" select="text/html" />
	<xsl:variable name="TEXT" select="text/plain" />

	<xsl:template match="/">
		<html>
			<body>
				<table>
					<xsl:apply-templates />
				</table>
			</body>
		</html>
	</xsl:template>

	<xsl:template match="node()">
	 <xsl:if test="normalize-space(node())">
		<tr>
			<td><xsl:value-of select="name(.)" /></td>
			<td>
			<xsl:variable name="content_type"
select="normalize-space(preceding-sibling::Content-type[2])"/>
				<xsl:value-of select="$content_type"/>
			<xsl:choose>
				<xsl:when test="$content_type=$HTML" >
				<xsl:value-of select="text()" disable-output-escaping="yes"/>
				</xsl:when>
				<xsl:otherwise>
				 <xsl:value-of select="text()"/>
				</xsl:otherwise>
			</xsl:choose>
			</td>
		</tr>
			<xsl:apply-templates/>
	 </xsl:if>
	</xsl:template>

</xsl:stylesheet>

On Mon, Mar 2, 2009 at 2:53 PM, David Carlisle <davidc@xxxxxxxxx> wrote:
>
>
> you haven't said what your problem was, or shown the code causing the
> problem.
> The test you posted should be Ok (if your processor supports d-o-e) if
> the variable HTML is set to the string 'text/html', or of course you
> could use this string directly. You don't need a variable here, but
> perhaps you use the same string in several places?
>
>
> Of course it's almost always the wrong thing to do to use d-o-e (but for
> copying fragmenst of html, it's perhaps forgivable)
>
>
> Apart from yur question about the test, matching on node() will produce
> a very strange result structure.
>
> on an element you produce a table row, and then apply templates to the
> element's children, which will be a text node typically which will also
> match the template and produce a row with two empty td, the fist td empty
> as a text node has "" for name() and the second td empty as a text node
> has no text node children so select="text() is empty.
>
>
>
> David
>
> ________________________________________________________________________
> The Numerical Algorithms Group Ltd is a company registered in England
> and Wales with company number 1249803. The registered office is:
> Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.
>
> This e-mail has been scanned for all viruses by Star. The service is
> powered by MessageLabs.
> ________________________________________________________________________


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent