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 Suzy Creamcheese <di...@yahoo.com> on 2007/03/17 21:41:27 UTC
Serializing the doctype (DTD) of an XML document
I am attempting to serialize, from scratch, an XML document with a DTD, that
is currently stored. I am using a DOMWriter and a LocalFileFormatTarget as
an XMLFormatTarget. I have seen examples in Java that use this
OutputFormat::setDoctype method to set the DTD, but I can not figure out an
equivalent or substitute way of doing this using the xerces-c API. I have
searched for a long time, but I seem to not be turning up the right things,
so any help would be much appreciated!
Thanks.
--
View this message in context: http://www.nabble.com/Serializing-the-doctype-%28DTD%29-of-an-XML-document-tf3420441.html#a9533206
Sent from the Xerces - C - Users mailing list archive at Nabble.com.
Re: Serializing the doctype (DTD) of an XML document
Posted by Suzy Creamcheese <di...@yahoo.com>.
I am creating the log from scratch, so I would think that I'd need a method
that does something like this. The DOMDocument interface specifies this
http://xml.apache.org/xerces-c/apiDocs/classDOMDocument.html#z57_8
'getDoctype' method but goes on to say
>> The DOM Level 2 does not support editing the Document Type Declaration.
>> docType cannot be altered in any way, including through the use of
>> methods inherited from the DOMNode interface, such as insertNode or
>> removeNode.
I'd like to be able to just set the doctype of the xml document I'm
synthesizing, I don't need to change it.
David Bertoni wrote:
>
> Suzy Creamcheese wrote:
>> I have tried using the XMLGrammarPool::serializeGrammars method but it
>> seems
>> to not be relevant to what I want to do, which is essentially to set the
>> doctype. Here's the source of me trying to do the serializeGrammars
>>
>> The serialize grammars thing doesn't make any sense to me. I tried it
>
> Serializing the grammar save a binary representation of the internal
> structures Xerces-C uses to do validation. You don't want that.
>
> Using the DOMPrint sample program, I parsed a trivial document with a
> DOCTYPE declaration and an external subset, and got the DOCTYPE
> declaration
> in the output. If you're not getting the same result, I suspect the DOM
> instance contains no DOCTYPE node, or perhaps you're expecting something
> else.
>
> Dave
>
>
--
View this message in context: http://www.nabble.com/Serializing-the-doctype-%28DTD%29-of-an-XML-document-tf3420441.html#a9551843
Sent from the Xerces - C - Users mailing list archive at Nabble.com.
Re: Serializing the doctype (DTD) of an XML document
Posted by David Bertoni <db...@apache.org>.
Suzy Creamcheese wrote:
> I have tried using the XMLGrammarPool::serializeGrammars method but it seems
> to not be relevant to what I want to do, which is essentially to set the
> doctype. Here's the source of me trying to do the serializeGrammars
>
> The serialize grammars thing doesn't make any sense to me. I tried it
Serializing the grammar save a binary representation of the internal
structures Xerces-C uses to do validation. You don't want that.
Using the DOMPrint sample program, I parsed a trivial document with a
DOCTYPE declaration and an external subset, and got the DOCTYPE declaration
in the output. If you're not getting the same result, I suspect the DOM
instance contains no DOCTYPE node, or perhaps you're expecting something else.
Dave
Re: Serializing the doctype (DTD) of an XML document
Posted by Suzy Creamcheese <di...@yahoo.com>.
I have tried using the XMLGrammarPool::serializeGrammars method but it seems
to not be relevant to what I want to do, which is essentially to set the
doctype. Here's the source of me trying to do the serializeGrammars
The serialize grammars thing doesn't make any sense to me. I tried it
DOMImplementationLS * impl = (DOMImplementationLS *)
DOMImplementationRegistry::getDOMImplementation(XS("[removed]"));
DOMWriter * writer = impl->createDOMWriter();
if (writer->canSetFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true))
writer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true);
if (writer->canSetFeature(XMLUni::fgDOMWRTBOM, true))
writer->setFeature(XMLUni::fgDOMWRTBOM, true);
std::auto_ptr<MemoryManager> mem_mgr = new MemoryManagerImpl();
std::auto_ptr<XMLGrammarPool> gp = new XMLGrammarPoolImpl(mem_mgr.get());
gp->cacheGrammar(m_grammar);
std::auto_ptr<XMLFormatTarget> ft = new
LocalFileFormatTarget(m_file.c_str());
std::auto_ptr<BinOutputStream> bp = new BinFileOutputStream((m_file +
"grammar").c_str());
gp->serializeGrammars(bp.get());
writer->writeNode(ft.get(), *m_doc);
writer->release();
And the grammar file looks like this http://zxcvbn.t35.com/test.xmlgrammar
Since this appears to be a dead-end, other ideas are appreciated
--
View this message in context: http://www.nabble.com/Serializing-the-doctype-%28DTD%29-of-an-XML-document-tf3420441.html#a9544834
Sent from the Xerces - C - Users mailing list archive at Nabble.com.