Hi Thiwanka, Aside from the previous discussion on the mailing list [1] and the specification I'm not aware of any good reading material on parseWithContext().
I have given the design more thought since last year and think it should be possible to implement this method (in the case where the context node is not a Document node) by synthesizing a wrapper XML document which contains a reference to the fragment and the necessary context (e.g. namespace declarations) required to parse the fragment. You can then transfer the nodes created for the fragment into the existing DOM. For example, if your existing document looked like this: <ns1:a xmlns:ns1="http://ns1"> <ns2:b xmlns:ns2="http://ns2"/> </ns1:a> and you wanted to insert an XML fragment like: <ns2:c/><ns1:d/> as a child of 'ns2:b', you could generate a wrapper document: <!DOCTYPE DUMMY_ROOT [ <!ENTITY fragment PUBLIC "***" "***"> ]> <DUMMY_ROOT xmlns:ns1="http://ns1" xmlns:ns2="http://ns2">&fragment;</DUMMY_ROOT> where the 'fragment' entity points to the XML fragment the user provided, parse the document you synthesized and then move the nodes created underneath the entity reference into the existing document, resulting in: <ns1:a xmlns:ns1="http://ns1"> <ns2:b xmlns:ns2="http://ns2"><ns2:c/><ns1:d/></ns2:b> </ns1:a> Hope that made sense. Thanks. [1] http://markmail.org/thread/ool7dyyzffor6o7b Michael Glavassevich XML Parser Development IBM Toronto Lab E-mail: [email protected] E-mail: [email protected] Thiwanka Somasiri <[email protected]> wrote on 03/28/2011 02:05:24 PM: > Hi Michael, > > As I understood, the second part of the project is also a critical > implementation, which is known as parseWithContext(). According to > the W3C specification[1], this method is used to insert a fragment > of and XML document to an existing document. The parameters in the > method specify the position where the new fragment should be > attached and which action should be triggered between the existing > document and the new fragment. > > The implementation also include an error handling part (in a case > where the inserting fragment is erroneous,etc) to notify the caller > through an ErrorHandler object when an unexpected scenario occur. > > I need to understand the background for parseWithContext() some more > and can you tell me what are the useful resources in this regard. > (Understanding the overall idea of this will help me to allocate > approximate time in the proposal) > > I would like to start writing a proposal for the project and I need > a big help from you. I am happy if you can give me an starting point > and guide lines to write the proposal. > > [1] http://www.w3.org/TR/2004/REC-DOM-Level-3-LS-20040407/load- > save.html#LS-LSParser-parseWithContext > > Thanks. > > On Sat, Mar 19, 2011 at 11:41 PM, Michael Glavassevich <[email protected] > > wrote: > Hi Thiwanka, > > Thiwanka Somasiri <[email protected]> wrote on 03/19/2011 02:25:03 AM: > > > Hi Michael, > > > > > Thanks for your reply. I will study more on the project within > > next week and come up with both my issues and ideas. Since I was > > having my exams, I could not focus much on the project and will be > > free after few more days. I hope the support of you all to step forward. > That's fine. It's still early on in the process so still quite a bit > of time to put together and discuss a proposal. > > > > Thanks. > > Thanks. > > Michael Glavassevich > XML Parser Development > IBM Toronto Lab > E-mail: [email protected] > E-mail: [email protected] > > > > -- > > Regards > > A.S.Thiwanka Somasiri > > Skype : executionerwild > MSN : [email protected]
