- Replace new line char with <br /> XSL
- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
- <xsl:template match="/">
- <xsl:for-each select="catalog/cd">
- <xsl:if test='contains(title,"
")'>
- <p>Found <xsl:value-of select="title" /></p>
- </xsl:if>
- </xsl:for-each>
- </xsl:template>
- </xsl:stylesheet>
- <catalog>
- <cd>
- <title>Empire
- Burlesque</title>
- <artist>Bob Dylan</artist>
- <country>USA</country>
- <company>Columbia</company>
- <price>10.90</price>
- <year>1985</year>
- </cd>
- <cd>
- <title>Hide your heart</title>
- <artist>Bonnie Tyler</artist>
- <country>UK</country>
- <company>CBS Records</company>
- <price>9.90</price>
- <year>1988</year>
- </cd>
- <cd>
- <title>Greatest Hits</title>
- <artist>Dolly Parton</artist>
- <country>USA</country>
- <company>RCA</company>
- <price>9.90</price>
- <year>1982</year>
- </cd>
- </catalog>
- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
- <xsl:output omit-xml-declaration="yes" indent="yes"/>
- <xsl:strip-space elements="*"/>
- <xsl:template match="/">
- <xsl:for-each select="catalog/cd">
- <xsl:variable name="title_clean">
- <xsl:call-template name="repNL">
- <xsl:with-param name="pText" select="title"/>
- </xsl:call-template>
- </xsl:variable>
- <p><xsl:value-of select='$title_clean' /></p>
- </xsl:for-each>
- </xsl:template>
- <xsl:template name="repNL">
- <xsl:param name="pText" select="."/>
- <xsl:copy-of select="substring-before(concat($pText,'
'),'
')"/>
- <xsl:if test="contains($pText, '
')">
- <br />
- <xsl:call-template name="repNL">
- <xsl:with-param name="pText" select=
- "substring-after($pText, '
')"/>
- </xsl:call-template>
- </xsl:if>
- </xsl:template>
- </xsl:stylesheet>
- <xsl:stylesheet version="1.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
- <xsl:output omit-xml-declaration="yes" indent="yes"/>
- <xsl:strip-space elements="*"/>
- <xsl:template match="node()|@*">
- <xsl:copy>
- <xsl:apply-templates select="node()|@*"/>
- </xsl:copy>
- </xsl:template>
- <xsl:template match="text()" name="repNL">
- <xsl:param name="pText" select="."/>
- <xsl:copy-of select=
- "substring-before(concat($pText,'
'),'
')"/>
- <xsl:if test="contains($pText, '
')">
- <br />
- <xsl:call-template name="repNL">
- <xsl:with-param name="pText" select=
- "substring-after($pText, '
')"/>
- </xsl:call-template>
- </xsl:if>
- </xsl:template>
- </xsl:stylesheet>
- <catalog>
- <cd>
- <title>Line1
- Line2
- Line3
- </title>
- <artist>Bob Dylan</artist>
- <country>USA</country>
- <company>Columbia</company>
- <price>10.90</price>
- <year>1985</year>
- </cd>
- <cd>
- <title>Empire
- Burlesque</title>
- <artist>Bob Dylan</artist>
- <country>USA</country>
- <company>Columbia</company>
- <price>10.90</price>
- <year>1985</year>
- </cd>
- <cd>
- <title>Hide your heart</title>
- <artist>Bonnie Tyler</artist>
- <country>UK</country>
- <company>CBS Records</company>
- <price>9.90</price>
- <year>1988</year>
- </cd>
- <cd>
- <title>Greatest Hits</title>
- <artist>Dolly Parton</artist>
- <country>USA</country>
- <company>RCA</company>
- <price>9.90</price>
- <year>1982</year>
- </cd>
- </catalog>
- <catalog>
- <cd>
- <title>Line1<br/> Line2<br/> Line3<br/>
- </title>
- <artist>Bob Dylan</artist>
- <country>USA</country>
- <company>Columbia</company>
- <price>10.90</price>
- <year>1985</year>
- </cd>
- <cd>
- <title>Empire<br/> Burlesque</title>
- <artist>Bob Dylan</artist>
- <country>USA</country>
- <company>Columbia</company>
- <price>10.90</price>
- <year>1985</year>
- </cd>
- <cd>
- <title>Hide your heart</title>
- <artist>Bonnie Tyler</artist>
- <country>UK</country>
- <company>CBS Records</company>
- <price>9.90</price>
- <year>1988</year>
- </cd>
- <cd>
- <title>Greatest Hits</title>
- <artist>Dolly Parton</artist>
- <country>USA</country>
- <company>RCA</company>
- <price>9.90</price>
- <year>1982</year>
- </cd>
- </catalog>