views:

78

answers:

1

I want to transform (with jquery.xslt.js) xml to be preserving tags in text nodes. Xml looks like:

<example>
   <text>
      Some text with <br /> and <img src="source" /> then text ....
   </text>
</example>

I want to have:

 <div class="example"> 
  <p>Some text with <br /> and <img src="source" /> then text ....</p> 
 </div>

If I use <xsl:value-of select="."/> I'll get

 "Some text with and then text ...."

If I add <xsl:apply-templates /> I'll get

"Some text with and then text .... <br/><img src="source" />"

Is there any way to exact rewrite content of tag?

A: 

Try something like this:

<xsl:template match="/example/text">
  <div class="example">
    <p>
      <xsl:copy-of select="@* | node()"/>
    </p>
  </div>
</xsl:template>
Andrew Hare