IBM WebSphere DataPower Community Forum IBM Webspere DataPower XI50
October 12, 2008, 03:09:40 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: IBM WebSphere DataPower SOA Appliance Forum - Just Launched come share your knowledge!!! These forums will be a great place to build a community. This site is not associated with IBM.
 
   Home   Help Search Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: <dp:serialize>  (Read 473 times)
atl30339
Newbie
*
Offline Offline

Posts: 3


View Profile
« on: February 21, 2008, 09:28:21 PM »

Hi all,

I need to serialize a XML doc to a string. DP provides <dp:serialize>, however, the end tags are not escaped
<abc/> ==> &lt;abc/>

and i would like to have
<abc/> ==> &lt;abc/&gt;

I have tried different ways: string replacement, disable-output-escaping attribute...etc, they all work fine in other XSLT engins but just not in DataPower. Angry

Any advice?

Cheers
Logged
atl30339
Newbie
*
Offline Offline

Posts: 3


View Profile
« Reply #1 on: February 25, 2008, 04:03:06 PM »

below code will do the work:  Grin

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">:

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

 <xsl:template match="text()">
   <xsl:call-template name="escape-gt">
     <xsl:with-param name="value" select="string(.)"/>
   </xsl:call-template>
 </xsl:template>

 <xsl:template name="escape-gt">
   <xsl:param name="value"/>
   <xsl:choose>
     <xsl:when test="contains ($value, '&gt;')">
       <xsl:value-of select="substring-before ($value, '&gt;')"/>
       <xsl:text disable-output-escaping="yes">&amp;gt;</xsl:text>
       <xsl:call-template name="escape-gt">
         <xsl:with-param name="value" select="substring-after ($value, '&gt;')"/>
       </xsl:call-template>
     </xsl:when>
     <xsl:otherwise>
       <xsl:value-of select="$value"/>
     </xsl:otherwise>
   </xsl:choose>
 </xsl:template>

</xsl:stylesheet>
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  



Powered by SMF | SMF © 2006-2007, Simple Machines LLC
Seo4Smf © Webmaster's Talks
This Site is not associated with IBM