xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Arvind Bassi <arvind_ba...@yahoo.co.uk>
Subject Problem: Extracting a String from CDATA Section
Date Tue, 03 Apr 2001 21:12:32 GMT
I am using Xalan to process a stylesheet and an incoming document, and
one of the nodes that is created is a CDATA node, as so:

		<Message_text>
			<xsl:text disable-output-escaping="yes">
			&lt;![CDATA[
			</xsl:text>
				<xsl:copy-of select="node()"/>
			<xsl:text disable-output-escaping="yes">				
			]]&gt;
			</xsl:text>		
		</Message_text>

becoming:

<Message_text>
<![CDATA[
<Trade_Document>.....</Trade_Document>
]]>
</Message_text>

I am copying the contents of the original document into the
Message_text node.

As part of my development l need to extract the contents of
<Message_text> into a String.

HOWEVER, I AM EXPERIENCING QUITE A FEW PROBLEMS.

Therefore, my code is as follows:

 NodeList elements = doc.getElementsByTagName("Message_text");

If the node was:

      <Message_text>Hello</Message_text>

The children nodes of "elements" is a Node.TEXT_NODE and l can get the
data.

However, if <Message_text> has a CDATA section then the children nodes
are (the separate values are separated by "|" pipes):

NODETYPE|NODENAME|NODEVALUE|hasChilren?
Node.PROCESSING_INSTRUCTION|javax.xml.transform.disable-output-escaping|false
Node.TEXT_NODE|#text|<![CDATA[|false
Node.PROCESSING_INSTRUCTION|javax.xml.transform.disable-output-escaping|false
Node.ELEMENT_NODE|Trade_Document|true
Node.PROCESSING_INSTRUCTION|javax.xml.transform.disable-output-escaping|false
Node.TEXT_NODE|#text|<![CDATA[|false
Node.PROCESSING_INSTRUCTION|javax.xml.transform.disable-output-escaping|false

Am l wrong in expecting the child node of "elements" (see above) to be
a Node.CDATA_SECTION_NODE? 

(and thus just use String s = node.getNodeValue() to get the value)

Is this a bug, or am l approaching the problem the wrong way?

Arvind.



____________________________________________________________
Do You Yahoo!?
Get your free @yahoo.co.uk address at http://mail.yahoo.co.uk
or your free @yahoo.ie address at http://mail.yahoo.ie

---------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
For additional commands, e-mail: general-help@xml.apache.org


Mime
View raw message