parsing an inner Xml inside XML

K

kris

hi,

I have a requirement to parse an XML which contains
another xml as a string content. I am able to parse the parent xml.
when I am parsing the second xml I am getting the following exception.
I have used CDATA to mark the string. And I have given the prolog
inside the inner xml which under one tag in the parent XML. I tried
without prolog also.

RdCanL::parseCanonical::XML EXCEPTION
org.apache.xmlbeans.XmlException: error: XML declaration is not well-
formed
at org.apache.xmlbeans.impl.store.Locale$SaxLoader.load(Locale.java:
3467)
at org.apache.xmlbeans.impl.store.Locale.parse(Locale.java:706)
at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java:
690)
at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java:
677)
at
org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.parse(SchemaTypeLoaderBase.java:
208)
at com.abc.fusion.rd.xmlbeans.ltm.LTCanDocument$Factory.parse(Unknown
Source)
at com.abc.fusion.rd.integration.RdCanL.parseCanonical(RdCanL.java:
124)
at
com.abc.fusion.rd.integration.RdCanBase.processCanonical(RdCanonicalBase.java:
287)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
at java.lang.reflect.Method.invoke(Method.java:324)
at
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:
287)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:
181)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:
148)
at
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:
96)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:
170)
at
org.springframework.orm.hibernate3.HibernateInterceptor.invoke(HibernateInterceptor.java:
97)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:
170)
at
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:
176)
at $Proxy47.processCanonical(Unknown Source)
 
A

Arne Vajhøj

kris said:
I have a requirement to parse an XML which contains
another xml as a string content. I am able to parse the parent xml.
when I am parsing the second xml I am getting the following exception.
I have used CDATA to mark the string. And I have given the prolog
inside the inner xml which under one tag in the parent XML. I tried
without prolog also.

If you extract the inner XML and it is valud XML you can parse it.

Based on what you write it is impossible to say what goes wrong.

Arne
 
A

Alexander.V.Kasatkin

hi,

I have a requirement to parse an XML which contains
another xml as a string content. I am able to parse the parent xml.
when I am parsing the second xml I am getting the following exception.
I have used CDATA to mark the string. And I have given the prolog
inside the inner xml which under one tag in the parent XML. I tried
without prolog also.

RdCanL::parseCanonical::XML EXCEPTION
org.apache.xmlbeans.XmlException: error: XML declaration is not well-
formed
at org.apache.xmlbeans.impl.store.Locale$SaxLoader.load(Locale.java:
3467)
at org.apache.xmlbeans.impl.store.Locale.parse(Locale.java:706)
at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java:
690)
at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java:
677)
at
org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.parse(SchemaTypeLoader-Base.java:
208)

If you use XML Beans to parse inner xml string, you should wrap
this xml string with <xml-fragment>...</xml-fragment> tags.
 
R

raja.vikram

If you use XML Beans to parse inner xml string, you should wrap
this xml string with <xml-fragment>...</xml-fragment> tags.- Hide quoted text -

- Show quoted text -

Hi
I tried with the <xml-fragment> tags too. Still it gives the same
exception.
Please find the XMLs below.

<?xml version="1.0" encoding="UTF-8"?>
<Integration>
<IntegrationHeader>
<SENDER>9812</SENDER>
<RECEIVER>9813</RECEIVER>
</IntegrationHeader>
<Content>
<xml-fragment>
<![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<Canonical xmlns:xsi="http://www.w3.org/2001/XMLSchema-
instance">
<DOCUMENT_TYPE>Load</DOCUMENT_TYPE>
</Canonical>]]>
</xml-fragment>
</Content>
</Integration>



I need to parse the XML injside <Content> tag. I tried with and
without having <xml-fragment> and CDATA. Still I am not able to parse
the inner XML using xml beans.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top