dbertoni 2003/01/28 22:54:49
Modified: c/samples/TransformToXercesDOM TransformToXercesDOM.cpp
Log:
Added comments. Use sanctioned API for creating a document.
Revision Changes Path
1.4 +36 -9
xml-xalan/c/samples/TransformToXercesDOM/TransformToXercesDOM.cpp
Index: TransformToXercesDOM.cpp
===================================================================
RCS file:
/home/cvs/xml-xalan/c/samples/TransformToXercesDOM/TransformToXercesDOM.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TransformToXercesDOM.cpp 24 Jan 2003 18:26:38 -0000 1.3
+++ TransformToXercesDOM.cpp 29 Jan 2003 06:54:49 -0000 1.4
@@ -13,12 +13,23 @@
-#include <xercesc/dom/impl/DOMDocumentImpl.hpp>
+#if !defined(NDEBUG) && defined(_MSC_VER)
+#include <crtdbg.h>
+#endif
+
+
+
+#include <xercesc/dom/DOMDocument.hpp>
+#include <xercesc/dom/DOMImplementation.hpp>
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/framework/LocalFileInputSource.hpp>
+#include <Include/XalanAutoPtr.hpp>
+
+
+
#include <XalanDOM/XalanDocument.hpp>
#include <XalanDOM/XalanElement.hpp>
@@ -62,21 +73,23 @@
XALAN_USING_XALAN(FormatterToXML)
XALAN_USING_XALAN(XercesDOMFormatterWalker)
- // OK, we're going to serialize the nodes that were
- // found. We should really check to make sure the
- // root (document) has not been selected, since we
- // really can't serialize a node list with the root.
+ // Create an output stream and a PrintWriter for the
+ // output
XalanStdOutputStream theStream(cout);
XalanOutputStreamPrintWriter thePrintWriter(theStream);
+ // We're going to serialize XML...
FormatterToXML theFormatter(thePrintWriter);
+ // Do pretty-printing...
theFormatter.setDoIndent(true);
theFormatter.setIndent(2);
XercesDOMFormatterWalker theWalker(theFormatter);
+ // This will walk the document and send
+ // events to the FormatterToXML.
theWalker.traverse(&theDocument);
}
@@ -88,13 +101,20 @@
const XalanParsedSource& theParsedSource,
const XalanCompiledStylesheet& theStylesheet)
{
- XALAN_USING_XERCES(DOMDocumentImpl)
+ XALAN_USING_XERCES(DOMDocument)
+ XALAN_USING_XERCES(DOMImplementation)
XALAN_USING_XALAN(FormatterToXercesDOM)
+ XALAN_USING_XALAN(XalanAutoPtr)
- DOMDocumentImpl theDocument;
+ // This is the document which we'll build...
+ const XalanAutoPtr<DOMDocument>
theDocument(DOMImplementation::getImplementation()->createDocument());
+ assert(theDocument.get() != 0);
- FormatterToXercesDOM theFormatter(&theDocument, 0);
+ // This is a class derived from FormatterListener, which
+ // we'll hook up to Xalan's output stage...
+ FormatterToXercesDOM theFormatter(theDocument.get(), 0);
+ // Do the transformation...
int theResult =
theTransformer.transform(
theParsedSource,
@@ -109,7 +129,7 @@
}
else
{
- serialize(theDocument);
+ serialize(*theDocument.get());
}
return theResult;
@@ -122,6 +142,13 @@
int argc,
const char* argv[])
{
+#if !defined(NDEBUG) && defined(_MSC_VER)
+ _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) |
_CRTDBG_LEAK_CHECK_DF);
+
+ _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
+ _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
+#endif
+
int theResult = 0;
if (argc != 3)
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]