S
shaun roe
I have an xml format for creating a database; lets say a fragment looks
like this:
<insertValue type="int">7</insert>
<insertValue type="string">Hello everyone</insert>
now I have a document I am transforming into this format using XSLT:
<nDwarves>7</nDwarves>
<snowWhiteSays>Hello everyone</snowWhiteSays>
<groupReply><possibleReplies replyTo="greeting">hello</possibleReplies>
<possibleReplies replyTo="workSignal">hi ho, hi ho</possibleReplies>
</groupReply>
My problem is that I want to put the entire contents of the <groupReply>
node into a string, escaping the "<" and ">", so that I have an
insertValue node containing the string which is essentially a bit of
escaped xml.
Unfortunately, <xsl:copy-of... > doesnt have an option to escape the xml
characters, so far as I can see. Is there another way?
background:
why do this?
I am using the Xerces2.3 parser to get the text content of the
<insertValue> nodes, then I upload it. If I have straight xml inside
this node, then getTextContent simply returns the collapsed text content
of all the child elements with no element names etc, when what I want
is the actual xml fragment to insert in my database as a string. I hope
to get around this by escaping the xml, so it really looks like just
another string.
like this:
<insertValue type="int">7</insert>
<insertValue type="string">Hello everyone</insert>
now I have a document I am transforming into this format using XSLT:
<nDwarves>7</nDwarves>
<snowWhiteSays>Hello everyone</snowWhiteSays>
<groupReply><possibleReplies replyTo="greeting">hello</possibleReplies>
<possibleReplies replyTo="workSignal">hi ho, hi ho</possibleReplies>
</groupReply>
My problem is that I want to put the entire contents of the <groupReply>
node into a string, escaping the "<" and ">", so that I have an
insertValue node containing the string which is essentially a bit of
escaped xml.
Unfortunately, <xsl:copy-of... > doesnt have an option to escape the xml
characters, so far as I can see. Is there another way?
background:
why do this?
I am using the Xerces2.3 parser to get the text content of the
<insertValue> nodes, then I upload it. If I have straight xml inside
this node, then getTextContent simply returns the collapsed text content
of all the child elements with no element names etc, when what I want
is the actual xml fragment to insert in my database as a string. I hope
to get around this by escaping the xml, so it really looks like just
another string.