本文整理汇总了C++中DOMLSSerializer::setFilter方法的典型用法代码示例。如果您正苦于以下问题:C++ DOMLSSerializer::setFilter方法的具体用法?C++ DOMLSSerializer::setFilter怎么用?C++ DOMLSSerializer::setFilter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DOMLSSerializer
的用法示例。
在下文中一共展示了DOMLSSerializer::setFilter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
errorsOccured = true;
}
// If the parse was successful, output the document data from the DOM tree
if (!errorsOccured && !errReporter->getSawErrors())
{
DOMPrintFilter *myFilter = 0;
try
{
// get a serializer, an instance of DOMLSSerializer
XMLCh tempStr[3] = {chLatin_L, chLatin_S, chNull};
DOMImplementation *impl = DOMImplementationRegistry::getDOMImplementation(tempStr);
DOMLSSerializer *theSerializer = ((DOMImplementationLS*)impl)->createLSSerializer();
DOMLSOutput *theOutputDesc = ((DOMImplementationLS*)impl)->createLSOutput();
// set user specified output encoding
theOutputDesc->setEncoding(gOutputEncoding);
// plug in user's own filter
if (gUseFilter)
{
// even we say to show attribute, but the DOMLSSerializer
// will not show attribute nodes to the filter as
// the specs explicitly says that DOMLSSerializer shall
// NOT show attributes to DOMLSSerializerFilter.
//
// so DOMNodeFilter::SHOW_ATTRIBUTE has no effect.
// same DOMNodeFilter::SHOW_DOCUMENT_TYPE, no effect.
//
myFilter = new DOMPrintFilter(DOMNodeFilter::SHOW_ELEMENT |
DOMNodeFilter::SHOW_ATTRIBUTE |
DOMNodeFilter::SHOW_DOCUMENT_TYPE);
theSerializer->setFilter(myFilter);
}
// plug in user's own error handler
DOMErrorHandler *myErrorHandler = new DOMPrintErrorHandler();
DOMConfiguration* serializerConfig=theSerializer->getDomConfig();
serializerConfig->setParameter(XMLUni::fgDOMErrorHandler, myErrorHandler);
// set feature if the serializer supports the feature/mode
if (serializerConfig->canSetParameter(XMLUni::fgDOMWRTSplitCdataSections, gSplitCdataSections))
serializerConfig->setParameter(XMLUni::fgDOMWRTSplitCdataSections, gSplitCdataSections);
if (serializerConfig->canSetParameter(XMLUni::fgDOMWRTDiscardDefaultContent, gDiscardDefaultContent))
serializerConfig->setParameter(XMLUni::fgDOMWRTDiscardDefaultContent, gDiscardDefaultContent);
if (serializerConfig->canSetParameter(XMLUni::fgDOMWRTFormatPrettyPrint, gFormatPrettyPrint))
serializerConfig->setParameter(XMLUni::fgDOMWRTFormatPrettyPrint, gFormatPrettyPrint);
if (serializerConfig->canSetParameter(XMLUni::fgDOMWRTBOM, gWriteBOM))
serializerConfig->setParameter(XMLUni::fgDOMWRTBOM, gWriteBOM);
//
// Plug in a format target to receive the resultant
// XML stream from the serializer.
//
// StdOutFormatTarget prints the resultant XML stream
// to stdout once it receives any thing from the serializer.
//
XMLFormatTarget *myFormTarget;
if (goutputfile)
myFormTarget=new LocalFileFormatTarget(goutputfile);
else
myFormTarget=new StdOutFormatTarget();