aspose file tools*
The moose likes XML and Related Technologies and the fly likes Extract CDATA from an element using xsl Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Extract CDATA from an element using xsl" Watch "Extract CDATA from an element using xsl" New topic
Author

Extract CDATA from an element using xsl

girish chandra
Greenhorn

Joined: May 20, 2013
Posts: 2
InputXML)

<A1Result xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<![CDATA[
<?xml version="1.0" encoding="UTF-8" ?>
<ABCD_XML_DATA>
<Header>
<MessageId>AGDMY1323292534488</MessageId>
</Header>
</ABCD_XML_DATA>
]]>
</A1Result>

I need this output using xsl:

<ABCD_XML_DATA>
<Header>
<MessageId>AGDMY1323292534488</MessageId>
</Header>
</ABCD_XML_DATA>

additional info, my input and output are written in/to varibales.i tried this,

<xsl:variable name="Data">
<xsl:value-of select="$A1Result" disable-output-escaping="yes"/>
</xsl:variable>

please suggest how to achieve this, thanks.
g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 464
    
    2
Suppose I place a bit in a concrete context of a template: keeping though variables you seem to like having.
girish chandra
Greenhorn

Joined: May 20, 2013
Posts: 2
Thanks for your response.

this got my issue resloved, (i am using dp xsl processor, so the name space dp); i was trying the same thing yesterday with no luck; i had to parse it to work.

<xsl:copy-of select="dp:parse(dp:variable('var://context/saved/MyRes')//*[local-name()='A1Result'])" disable-output-escaping="yes"/>


where, 'var://context/saved/MyRes', has the input xml from question.
g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 464
    
    2
Ok, thanks for the feedback, glad to hear the problem is behind.

I just take this opportunity to correct two careless typos in my above post in order not to confuse other readers eventual:
[1] Line #2: name="$A1Result" should be read name="A1Result", of course by syntax.
[2] Line #6: $payload should be read $A1Result, being clear from the context of it.
Thanks for the attentions.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Extract CDATA from an element using xsl
 
Similar Threads
Rendering HTML content of the xml file
How do I recover the String
How to remove the header (Junk Characters) in transformed document?
How to generate XSL file for cxml document
Can XPath read CDATA?