|
Subject: RE: [xsl] Probelm with xsl:value-of in CSV to XML transform From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Fri, 4 Apr 2008 11:06:12 +0800 |
Thanks. The main things that come to mind are:
(a) No comments in the code (see parallel thread)!
(b) <xsl:text disable-output-escaping="yes"><![CDATA[</xsl:text>
You really don't want to be doing that. I think David explained why.
(c) <xsl:for-each select="node()">
<xsl:choose>
<xsl:when test="name()='daytime'">
You are hand-coding an apply-templates here. Put the contents of each
xsl:when branch into a template rule
<xsl:template match="daytime">
and replace the xsl:for-each with xsl:apply-templates.
If you must test the current element name in an xsl:when, don't use
test="name()='x'", use test="self::x".
(d) <xsl:element name="daytime">
Write a literal result element <daytime>
(e) <xsl:when test="text()='yes'">
Don't test the contents of a text node, test the string value of the
containing element:
<xsl:when test=".='yes'">
It doesn't really make a difference here because you generated the XML and
you know there are no comments or processing instructions; but it's a bad
habit to get into because one day an XML instance will arrive containing
comments and your code will fail.
Michael Kay
http://www.saxonica.com/
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| RE: [xsl] Probelm with xsl:value-of, Marney Cotterill | Thread | Re: [xsl] Probelm with xsl:value-of, David Carlisle |
| RE: [xsl] XSL 2.0 - value-of - xml:, Robert Koberg | Date | RE: [xsl] XSL 2.0 - value-of - xml:, Michael Kay |
| Month |