M
Martin Plantec
Hello,
I have done research to solve one of my problems, but the solution I
found fails with an error message. Here is the (simple, beginner level)
problem. My XML is:
<para>
<line>This is the first line.</line>
<line>This is the second line.</line>
<line>This is the third line.</line>
</para>
I would like to get the obvious XHTML for that, namely:
<p>This is the first line.<br />
This is the second line.<br />
This is the third line.</p>
In other words, I don't want a <br /> at the end if it's the last line.
Here is the solution I have assembled based on my research:
<xsl:template match="para">
<p>
<xsl:for-each select="line">
<xsl:apply-templates />
<xsl:if test="position() < last()">
<br />
</xsl:if>
</xsl:for-each>
</p>
</xsl:template>
I am doing server-side transformation with PHP using Sabltron as
back-end. Error message is :
Warning: Sablotron error on line 45: XML parser error 4: not
well-formed (invalid token) in C:\path...\page.php on line 25
FAILURE : XML parser error 4: not well-formed (invalid token) ; error
code is 2
What am I doing wrong?
Thank you,
Martin
I have done research to solve one of my problems, but the solution I
found fails with an error message. Here is the (simple, beginner level)
problem. My XML is:
<para>
<line>This is the first line.</line>
<line>This is the second line.</line>
<line>This is the third line.</line>
</para>
I would like to get the obvious XHTML for that, namely:
<p>This is the first line.<br />
This is the second line.<br />
This is the third line.</p>
In other words, I don't want a <br /> at the end if it's the last line.
Here is the solution I have assembled based on my research:
<xsl:template match="para">
<p>
<xsl:for-each select="line">
<xsl:apply-templates />
<xsl:if test="position() < last()">
<br />
</xsl:if>
</xsl:for-each>
</p>
</xsl:template>
I am doing server-side transformation with PHP using Sabltron as
back-end. Error message is :
Warning: Sablotron error on line 45: XML parser error 4: not
well-formed (invalid token) in C:\path...\page.php on line 25
FAILURE : XML parser error 4: not well-formed (invalid token) ; error
code is 2
What am I doing wrong?
Thank you,
Martin