[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Problem retaining HTML tags during XSL transformation

Subject: Problem retaining HTML tags during XSL transformation
From: <Ambika.Das@xxxxxxxxxxxxxxxxxx>
Date: Wed, 10 Jan 2007 21:46:07 +0530
br tags in xslt
Hi All,

I am facing some problem in retaining the HTML tags during XSL
transformation.
Given below are the details.

Input XML:

<?xml version="1.0" encoding="UTF-8" ?>
<elem id="11" date="10 Jan 2007" time="16:55">
Non Title
<title>Title Here</title>
<text>
<PRE> (Start of pre tag)
<p>
Within P
</p>
After P tag
(End of pre tag) </PRE></text>
</elem>

XSL Code:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="html" indent="no"/>

   <xsl:template match="*">
		<xsl:copy>
		<xsl:copy-of select="@*"/>
		<xsl:apply-templates/>
		</xsl:copy>
	</xsl:template>

  	<xsl:template match="elem">
		<xsl:text>Elem Id, News Details&#10;</xsl:text>
		<xsl:value-of select="@id"/>
		<xsl:text>,"</xsl:text>
		<xsl:call-template name="transformXMLString">
		    <xsl:with-param name="StringToTransform" select="$doubleQtReplaced"/>
		</xsl:call-template>
		<xsl:text>"</xsl:text>
	</xsl:template>

	<xsl:variable name="doubleQtReplaced">
        <xsl:call-template name="replaceDblQt">
            <xsl:with-param name="StringToTransform" select="/"/>
        </xsl:call-template>
    </xsl:variable>

	<xsl:template match="error">
		<xsl:text>SYSERROR_TYPE,SYSERROR_CODE,SYSERROR_DESC&#10;X,730,"</xsl:text>
		    <xsl:value-of select="error_text"/>
		<xsl:text>"</xsl:text>
	</xsl:template>

	<xsl:template  name="transformXMLString">
	    <xsl:param name="StringToTransform" select="."/>
	    <xsl:choose>
            <xsl:when test="contains($StringToTransform,'&#10;')">
                <xsl:value-of
select="substring-before($StringToTransform,'&#10;')"
/><br/><xsl:call-template name="transformXMLString">
                        <xsl:with-param name="StringToTransform">
                            <xsl:value-of
select="substring-after($StringToTransform,'&#10;')" />
                        </xsl:with-param>
                    </xsl:call-template>
            </xsl:when>
	        <xsl:otherwise>
	            <xsl:value-of select="$StringToTransform"/>
	        </xsl:otherwise>
	    </xsl:choose>
	</xsl:template>

	<xsl:template name="replaceDblQt">
	    <xsl:param name="StringToTransform" select ="."/>
	    <xsl:choose>
	        <xsl:when test="contains($StringToTransform,'&#x22;')">
                <xsl:value-of
select="substring-before($StringToTransform,'&#x22;')"/>""<xsl:call-template
name="replaceDblQt">
                        <xsl:with-param name="StringToTransform">
                            <xsl:value-of
select="substring-after($StringToTransform,'&#x22;')"/>
                        </xsl:with-param>
                    </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
	            <xsl:value-of select="$StringToTransform"/>
	        </xsl:otherwise>
	    </xsl:choose>
	</xsl:template>

</xsl:stylesheet>

Current Output:

Elem Id, News Details

11,"<br>Non Title<br>Title Here<br><br> (Start of pre tag) <br><br>Within
P<br><br>After P tag<br>(End of pre tag) <br>"

Desired output:

Elem Id, News Details

11,"<br>Non Title<br><title>Title Here</title><br><br> <PRE>(Start of pre tag)
<br><p>Within P</p><br>After P tag<br>(End of pre tag) </PRE> <br>"

Any clues?

Thanks and Regards,
 
A P Das

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.