5 users online. Create an account or sign in to join them.Users
why does a formatted text not preserve the <p> tag
This is an open discussion with 5 replies, filed under XSLT.
Search
value-of is supposed to strip all elements before returning the value. To preserve them you have to use copy-of:
<h1><xsl:copy-of select="/data/test/entry/tekst1/*"/></h1>
Thanks. Learned another thing.
Another tip: don't put <P/>aragraph elements inside <H1/> elements :P
Davidhund : also thanks for this tip.
You can also use this:
<xsl:apply-templates select="tekst1/* | tekst1/text()" mode="html"/>
(you need to include the typography.xsl utility that ships with Symphony). This would output recursively any node and text value of your xml fragment, and you can also override certain elements you need to straighten.
Create an account or sign in to comment.
If I have this piece of xml :
<test> <section id="8" handle="test">test</section> <entry id="11"> ` `<tekst1 mode="formatted"> <p>Dit is een formatted tekst. </p> <p>En dit is regel 2</p> ` `</tekst1> </entry>And I use this xslt :
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" omit-xml-declaration="yes" encoding="UTF-8" indent="yes" /> <xsl:template match="/"> <h1><xsl:value-of select="/data/test/entry/tekst1"/></h1> </xsl:template> <:/xsl:stylesheet>Then the output is this :
So the
has disappear. Is this normal behaviour and if so, how can I preserve the
<p>and<br>tags ?