You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by jadiyo <ni...@lgim.co.uk> on 2006/04/20 15:31:05 UTC
containing well formed XML Documents
Hi,
I seem to be having a problem that a lot of people are experiencing!
I am working with a 3rd party schema which has the following type
definition:
.....
.....
<xs:complexType name="Text" mixed="true">
<xs:complexContent>
<xs:extension base="xs:anyType">
<xs:sequence />
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:element name="MessageText" type="Text" />
.....
.....
The MessageText element is defined to hold anyType. In my case, it actually
holds at
least 2 (well formed/complete) XML documents.
The XML shown below is a snippet of the overall XML reveived.
<MessageText>
<ah:AppHdr xmlns:ah="urn:swift:xsd:$ahV10">
<ah:MsgRef>the message ref</ah:MsgRef>
<ah:CrDate>2006-04-18T16:04:55.739+01:00</ah:CrDate>
</ah:AppHdr>
<Doc:Document xmlns:Doc="urn:swift:xsd:swift.ia$setr.010.001.02">
<Doc:setr.010.001.02>
<Doc:MsgNm>setr.010.001.02</Doc:MsgNm>
</Doc:setr.010.001.02>
</Doc:Document>
</MessageText>
AppHdr is a complete XML document in its own right, as is
Document.
When I use XMLBeans to get to the MessageText content, it gets wrapped
in an <xml-fragment> as shown below.
<xml-fragment xmlns:urn="urn:swift:xsd:saa.mxs.01>
<ah:AppHdr xmlns:ah="urn:swift:xsd:$ahV10">
<ah:MsgRef>the message ref</ah:MsgRef>
<ah:CrDate>2006-04-18T16:04:55.739+01:00</ah:CrDate>
</ah:AppHdr>
<Doc:Document xmlns:Doc="urn:swift:xsd:swift.ia$setr.010.001.02">
<Doc:setr.010.001.02>
<Doc:MsgNm>setr.010.001.02</Doc:MsgNm>
</Doc:setr.010.001.02>
</Doc:Document>
</xml-fragment>
I need to extract AppHdr and Document individually so they they themsleves
can be
parsed with XMLBeans.
I'd appreciate any help at all.
Many Thanks
Nirmal
--
View this message in context: http://www.nabble.com/%3Cxml-fragment%3E-containing-well-formed-XML-Documents-t1480526.html#a4007281
Sent from the Xml Beans - User forum at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org
Re: SV: containing well formed XML Documents
Posted by jadiyo <ni...@lgim.co.uk>.
You are a genius!
The first approach didn't work for some reason, but using XmlCursor worked a
treat.
Thanks for the quick (and working) response.
FYI, the first approach approach returned <xml-fragment></xml-fragment> when
I sent to stdout
Nirmal
--
View this message in context: http://www.nabble.com/%3Cxml-fragment%3E-containing-well-formed-XML-Documents-t1480526.html#a4010624
Sent from the Xml Beans - User forum at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org
RE: SV: containing well formed XML Documents
Posted by jadiyo <ni...@lgim.co.uk>.
Thanks Cezar.
I tried this and it worked.
The only problem I found is that the xmlns attribute is lost. So, instead
of seeing
<AppHdr xmlns="urn:swift:xsd:$ahV10"> I only see <urn:AppHdr>
Any ideas?
Thanks again
Nirmal
--
View this message in context: http://www.nabble.com/%3Cxml-fragment%3E-containing-well-formed-XML-Documents-t1480526.html#a4185490
Sent from the Xml Beans - User forum at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org
Re: SV: containing well formed XML Documents
Posted by jadiyo <ni...@lgim.co.uk>.
Hi again,
What approach would be best to create this particular part of the document.
As mentioned before, the element will contain any number of well formed
documents.
In my case, I have 2 documents to add to the MessageText. These documents
are created independently. Any attempt to add the 2 documents to the
MessageText, results in them being wrapped in a CDATA. Ideally, what I
would like is something like this.
<MessageText>
<ah:AppHdr xmlns:ah="urn:swift:xsd:$ahV10">
<ah:From>
<ah:Type>ei Type From</ah:Type>
<ah:Id>ei ID From</ah:Id>
</ah:From>
</ah:AppHdr>
<Doc:Document xmlns:Doc="urn:swift:xsd:swift.if.ia$setr.010.001.02">
<Doc:MstrRef>the Master Reference</Doc:MstrRef>
</Doc:Document>
</MessageText>
Again, many thanks in advance.
Nirmal
--
View this message in context: http://www.nabble.com/%3Cxml-fragment%3E-containing-well-formed-XML-Documents-t1480526.html#a4136239
Sent from the Xml Beans - User forum at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org
SV: containing well formed XML Documents
Posted by Mi...@connecta.se.
Hi Nirmal.
What happends if you just get the first child from the domnode?
Node node = messagetext.getDomNode().getFirstChild();
AppHdr ah = AppHdr.Factory.parse( node );
node = messagetext.getDomNode().getLastChild();
Document doc = Document.Factory.parse( node );
or with cursor:
XmlCursor cur = messagetext.newCursor();
cur.toChild( 0 );
AppHdr ah = AppHdr.Factory.parse( cur.getDomNode() );
cur.toNextSibling();
Document doc = Document.Factory.parse( cur.getDomNode() );
Regards
/Mikael
________________________________
Fr�n: jadiyo [mailto:nirmal.patel@lgim.co.uk]
Skickat: to 2006-04-20 15:31
Till: user@xmlbeans.apache.org
�mne: <xml-fragment> containing well formed XML Documents
Hi,
I seem to be having a problem that a lot of people are experiencing!
I am working with a 3rd party schema which has the following type
definition:
.....
.....
<xs:complexType name="Text" mixed="true">
<xs:complexContent>
<xs:extension base="xs:anyType">
<xs:sequence />
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:element name="MessageText" type="Text" />
.....
.....
The MessageText element is defined to hold anyType. In my case, it actually
holds at
least 2 (well formed/complete) XML documents.
The XML shown below is a snippet of the overall XML reveived.
<MessageText>
<ah:AppHdr xmlns:ah="urn:swift:xsd:$ahV10">
<ah:MsgRef>the message ref</ah:MsgRef>
<ah:CrDate>2006-04-18T16:04:55.739+01:00</ah:CrDate>
</ah:AppHdr>
<Doc:Document xmlns:Doc="urn:swift:xsd:swift.ia$setr.010.001.02">
<Doc:setr.010.001.02>
<Doc:MsgNm>setr.010.001.02</Doc:MsgNm>
</Doc:setr.010.001.02>
</Doc:Document>
</MessageText>
AppHdr is a complete XML document in its own right, as is
Document.
When I use XMLBeans to get to the MessageText content, it gets wrapped
in an <xml-fragment> as shown below.
<xml-fragment xmlns:urn="urn:swift:xsd:saa.mxs.01>
<ah:AppHdr xmlns:ah="urn:swift:xsd:$ahV10">
<ah:MsgRef>the message ref</ah:MsgRef>
<ah:CrDate>2006-04-18T16:04:55.739+01:00</ah:CrDate>
</ah:AppHdr>
<Doc:Document xmlns:Doc="urn:swift:xsd:swift.ia$setr.010.001.02">
<Doc:setr.010.001.02>
<Doc:MsgNm>setr.010.001.02</Doc:MsgNm>
</Doc:setr.010.001.02>
</Doc:Document>
</xml-fragment>
I need to extract AppHdr and Document individually so they they themsleves
can be
parsed with XMLBeans.
I'd appreciate any help at all.
Many Thanks
Nirmal
--
View this message in context: http://www.nabble.com/%3Cxml-fragment%3E-containing-well-formed-XML-Documents-t1480526.html#a4007281
Sent from the Xml Beans - User forum at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org