You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jaxme-dev@ws.apache.org by Jose Luis Huertas Fernández <jo...@gmail.com> on 2007/03/28 19:36:09 UTC

XML inside another XML

Hi everybody,

thanks for this wonderful framewok... it is saving me tons of time!

What I need to do now is send an XML to another system (the XML is defined
by a XSD), but the content of one of the elements is an XML too. I was
trying to use a CDATA section because the "inner" XML does't have to be
interpreted but I don't know how to do it with JaxMe...

So, summarizing, what I need is that a String in a JaxMe bean will be
surrounded by a CDATA section when the bean is marshalled into XML... is it
possible?

Thanks in advance.

José Luis.

Re: XML inside another XML

Posted by Jochen Wiedmann <jo...@gmail.com>.
On 3/28/07, Jose Luis Huertas Fernández
<jo...@gmail.com> wrote:

> What I need to do now is send an XML to another system (the XML is defined
> by a XSD), but the content of one of the elements is an XML too. I was
> trying to use a CDATA section because the "inner" XML does't have to be
> interpreted but I don't know how to do it with JaxMe...
>
> So, summarizing, what I need is that a String in a JaxMe bean will be
> surrounded by a CDATA section when the bean is marshalled into XML... is it
> possible?

First of all, you do not necessarily need a CDATA section, don't you?
The XML parser will return the "inner" XML document as a string
anyways.

Second, if you *must* have a CDATA section, then I'd recommend the
following approach: First of all, create your "inner" document and
marshal it to a string, as you would do anyways. Second, create your
"outer" document and put the "inner" document in the corresponding
property. Third, do not marshal the "outer" document directly. Instead
create an instance of TransformerHandler. The TransformerHandler has
an associated Transformer. On that Transformer, set the property
CDATA_SECTION_ELEMENTS, see

http://java.sun.com/j2se/1.4.2/docs/api/javax/xml/transform/OutputKeys.html#CDATA_SECTION_ELEMENTS


Jochen



-- 
My cats know that I am a loser who goes out for hunting every day
without ever returning as much as a single mouse. Fortunately, I've
got a wife who's a real champ: She leaves the house and returns within
half an hour, carrying whole bags full of meal.

---------------------------------------------------------------------
To unsubscribe, e-mail: jaxme-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: jaxme-dev-help@ws.apache.org