Shanmugalakshmi
Shanmugalakshmi

Reputation: 267

Split the text between the tag in xsl

I have a xml with below structure.

<p>Simple XML will return a reference to an <i>object</i> containing: <quote><p>the node value and you cant use references in session variables</p></quote> as there is <b>no feasible</b> way to restore a reference to another variable.</p>

The output should be follow

<p>Simple XML will return a reference to an <i>object</i> containing:<p>
<blockquote>the node value and you cant use references in session variables</blockquote>
<p>as there is <b>no feasible</b> way to restore a reference to another variable.</p>

How is possible to split the tags with emphasis. Thanks in advance.

Upvotes: 0

Views: 122

Answers (1)

Baderous
Baderous

Reputation: 1069

If you want to do it with XSLT, here's a possible solution:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    exclude-result-prefixes="xs"
    version="2.0">

    <xsl:template match="@*|node()">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
    </xsl:template>

    <xsl:template match="quote">
        <xsl:text disable-output-escaping="yes"><![CDATA[</p>]]></xsl:text>
        <blockquote><xsl:apply-templates select="@*|node()"/></blockquote>
        <xsl:text disable-output-escaping="yes"><![CDATA[<p>]]></xsl:text>
    </xsl:template>

    <xsl:template match="quote/p">
        <xsl:value-of select="."/>
    </xsl:template>

</xsl:stylesheet>

Upvotes: 2

Related Questions