----------------------------------------
Exemplo inserindo CDATA
----------------------------
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" cdata-section-elements="request-item-list" version="1.0" indent="yes"/>
<xsl:strip-space elements="*" />
<xsl:template match="/">
<xsl:variable name="BODY" select="/ROOT/BODY/data"></xsl:variable>
<mes:payload>
<xsl:text disable-output-escaping="yes"><![CDATA[<]]></xsl:text>![CDATA[<xsl:value-of select="concat('<','request-item-list','>')" />
<xsl:for-each select="$BODY/request_item_list" >
<xsl:value-of select="concat('<','item','>')" />
<xsl:value-of select="concat('<area-code>',./area_code,'<area-code>')" />
<xsl:value-of select="concat('<lob>',./lob,'<lob>')" />
<xsl:value-of select="concat('<product-code>',./product_code,'>product-code>')" />
<xsl:value-of select="concat('<','/item','>')" />
</xsl:for-each>]]<xsl:text disable-output-escaping="yes"><![CDATA[>]]></xsl:text>
</mes:payload>
</xsl:template>
</xsl:stylesheet>
----------------------------------------
Obtendo CDATA
-------------------------------------
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" />
<xsl:variable name="PAYLOAD" select="/ROOT/BODY/OUTPUT/*[local-name()='Envelope']/*[local-name()='Body']/*[local-name()='executeSyncResponse']/*[local-name()='message']/*[local-name()='payload']" />
<xsl:template match="/">
<OUTPUT>
<xsl:value-of select="$PAYLOAD" disable-output-escaping="yes" />
</OUTPUT>
</xsl:template>
</xsl:stylesheet>
No comments:
Post a Comment