Reputation: 438
Is it possible to add something like that:
<?xml version="1.0" encoding="UTF-8"?>
to WSO2 XML Formatter in inline section? I see that tag is always added before tag "eventFormatter", but when I pass the event through CEP and I get the answer in my queue, the output XML doesn't have this tag.
If I want add it in inline section I get this error:
Failed to update event formatter, Exception: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[7,10] Message: The processing instruction target matching "[xX][mM][lL]" is not allowed.
//Udpate
My Formatter looks like:
<?xml version="1.0" encoding="UTF-8"?>
<eventFormatter name="Formatter_XML_Out" statistics="disable"
trace="disable" xmlns="http://wso2.org/carbon/eventformatter">
<from streamName="Test_stream_out_xml" version="1.0.0"/>
<mapping customMapping="enable" type="xml">
<inline>
<Event>
<Name>{{Name}}</Name>
<Surname>{{Surname}}</Surname>
</Event>
</inline>
</mapping>
<to eventAdaptorName="ActiveMQ_Output" eventAdaptorType="jms">
<property name="transport.jms.Destination">myQueue</property>
</to>
</eventFormatter>
I get this in output message:
<Event>
<Name>XXXX</Name>
<Surname>YYYYY</Surname>
</Event>
Why this tag <?xml version="1.0" encoding="UTF-8"?>
is gone?
Upvotes: 0
Views: 331
Reputation: 912
It seems that WSO2CEP 3.x cannot format the message when using an XML mapping with the <?xml version="1.0" encoding="UTF-8"?>
tag.
A workaround is to use Text mapping instead as follows
<?xml version="1.0" encoding="UTF-8"?>
<eventFormatter name="Formatter_XML_Out" statistics="disable"
trace="disable" xmlns="http://wso2.org/carbon/eventformatter">
<from streamName="Test_stream_out_xml" version="1.0.0"/>
<mapping customMapping="enable" type="text">
<inline>
<![CDATA[
<?xml version="1.0" encoding="UTF-8"?>
<Event>
<Name>{{Name}}</Name>
<Surname>{{Surname}}</Surname>
</Event>
]]>
</inline>
</mapping>
<to eventAdaptorName="ActiveMQ_Output" eventAdaptorType="jms">
<property name="transport.jms.Destination">myQueue</property>
</to>
</eventFormatter>
use type="text" here.
Upvotes: 1
Reputation: 31110
No. The ?xml
text declaration must appear at the beginning of the document:
The text declaration MUST NOT appear at any position other than the beginning of an external parsed entity.
This is enforced by XML parsers.
From your edit, it looks like you want your output document to include a declaration. The only way to control this would be through the outer eventFormatter
configuration. The documentation doesn't show a way to do this.
However, there's no need for it - UTF-8 is already the default in the absence of a declaration, so it can be omitted.
Upvotes: 0