It seems Saxon does'nt seem to handle hetrogeneous sequence
following-sibling::text()[1] | a properly (I might be wrong..)
yes, you are wrong. Your code has at least three errors:
<xsl:with-param name="nodelist"
select="following-sibling::text()[1] | a" />
(a) this selects only the first text node, there might be a text node before
the <a> and another one after
(b) it's looking for a elements that are children of <header> rather than
siblings
(c) it doesn't discriminate between nodes that come before the next header
and nodes that come after.
Please see the solutions I posted this morning.
Michael Kay
http://www.saxonica.com/
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes"/>
<xsl:template match="/root">
<html>
<head>
<title/>
</head>
<body>
<xsl:apply-templates select="header" />
</body>
</html>
</xsl:template>
<xsl:template match="header">
<h1><xsl:value-of select="." /></h1>
<xsl:call-template name="printTextNode">
<xsl:with-param name="nodelist"
select="following-sibling::text()[1] | a" />
</xsl:call-template>
</xsl:template>
<xsl:template name="printTextNode">
<xsl:param name="nodelist" />
<p>
<xsl:for-each select="$nodelist">
<xsl:choose>
<xsl:when test="name() = 'a'">
<xsl:copy-of select="." />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="." />
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</p>
</xsl:template>
</xsl:stylesheet>
Regards,
Mukul
On 8/17/05, Noam Raphael <noamraph(_at_)gmail(_dot_)com> wrote:
Hello,
I'm very new to XSL, so please forgive me if this question
is stupid.
I want to transform an XML document which looks like this:
=====================
<header>
First Section
</header>
This section deals with a lot of <a href="bla.htm">things</a>.
One of them, is...
<header>
Second Section
</header>
Now, this section is different, becase...
=====================
into this HTML:
=====================
<h1>First Section</h1>
<p>This section deals with a lot of <a href="bla.htm">things</a>.
One of them, is...</p>
<h1>Second Section</h1>
<p>Now, this section is different, bacause...</p>
=====================
I have a problem with adding the <p></p> tags. The problem is that
their locations depends on the <header> tags. I can, of
course, add a
</p> before a header and a <p> after it, but I'll get an
extra one at
the beginning and at the end. Can I do this transformation with XSL?
(If it matters, I used <xsl:for-each select="text() | *">)
Thank you very much,
Noam Raphael
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--