You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xerces.apache.org by Ben Griffin <be...@redsnapper.net> on 2009/03/05 12:17:13 UTC
DOMDocumentFragment from XMLCh
How do I instantiate a DOMDocumentFragment from a XMLCh* (or XMLByte* )?
Alternatively, where can I find sample code for that?
Thanks in advance!
Re: DOMDocumentFragment from XMLCh
Posted by Ben Griffin <be...@redsnapper.net>.
David Bertoni wrote:
> Ben Griffin wrote:
>> How do I instantiate a DOMDocumentFragment from a XMLCh* (or
>> XMLByte* )?
>> Alternatively, where can I find sample code for that?
> If the stream contains a well-formed document, you can just parse it
> using one of the DOM parsers. See the MemParse sample for the
> details.
>
> Is there some reason you need a document fragment, rather than just
> a document? Perhaps it's because the stream doesn't contain a well-
> formed document? If that's the case, you'll need to wrap it in a
> single root element to parse it.
Actually, it was a mistake on my behalf.
I used the 'wrap in a root element' trick, and then realised that it
wasn't going to give me what I wanted anyway.
It turned out that what I wanted was a DOMLSInput so that I could use
parseWithContext - which (unfortunately) is not supported, so I had to
roll my own, which allowed for me to parse in a DOMDocument , or
handle attributes etc. separately - which provided a far better, and
context-sensitive, solution.
My basic home-rolled parseWithContext is not much more of a switch of
( contextNode->getNodeType()), with each case having another switch
across the ActionType parameter - but it appears to to what I need it
to do. (I was hoping that parseWithContext would be implemented of
course!)
However, thanks for your suggestion!
- Ben.
Re: DOMDocumentFragment from XMLCh
Posted by David Bertoni <db...@apache.org>.
Ben Griffin wrote:
> How do I instantiate a DOMDocumentFragment from a XMLCh* (or XMLByte* )?
> Alternatively, where can I find sample code for that?
If the stream contains a well-formed document, you can just parse it
using one of the DOM parsers. See the MemParse sample for the details.
Is there some reason you need a document fragment, rather than just a
document? Perhaps it's because the stream doesn't contain a well-formed
document? If that's the case, you'll need to wrap it in a single root
element to parse it.
Dave