#include "cconsolestream.h"
#include "cfilestream.h"
using namespace P6R;
using namespace P6EXAMPLES;
namespace {
{
if(
P6SUCCEEDED(err = cpFileInit->initialize(pszFilepath))) {
}
}
return err;
}
{
if(
P6SUCCEEDED(err = cpDOM->initialize(P6DOMXML_NOFLAGS,pOutStream))) {
}
}
return err;
}
{
if(
P6SUCCEEDED(err = cpXPath->initialize(P6XPATH_NOFLAGS,pOutStream))) {
}
}
return err;
}
{
"[ \"table\", " \
" { \"class\" : \"test-table\", " \
" \"style\" : \"background-color:purple\" }, " \
" [ \"row1\", \"row1-value\" ], " \
" [ \"row2\" ], " \
" \"mixed content has text anywhere\", " \
" [ \"ro";
"w3\", { \"id\" : 2345 } ]," \
" [ \"row4\", " \
" [ \"column1\", 5 ], " \
" [ \"column2\", \"10\" ] " \
" ]," \
" \"test text\" " \
"]";
cpStr->strlen( pJsonML1, 100000, &bufSize );
if (
P6SUCCEEDED( err )) err = cpStream->processStream( pJsonML1, bufSize );
cpStr->strlen( pJsonML2, 100000, &bufSize );
if (
P6SUCCEEDED( err )) err = cpStream->processStream( pJsonML2, bufSize );
cpStream = NULL;
err = cpXPath->compileExpression(
P6CTEXT(
"/table/row4/column1"), 19, NULL );
err = cpXPath->eval( cpDOM, NULL, NULL, &result );
{
err = cpNode->getName( &pString, &length );
pConsole->
writeStdout(
"getName failed [ %1$ ]\n",&args[0],1,NULL);
return eFail;
}
retval = -1;
err = cpStr->wstrncmp(
P6CTEXT(
"column1"), pString, 7, &retval );
if (0 != retval) {
pConsole->
writeStdout(
"Error: expected [ column1 ] but got [ %1$ ]\n",&args[0],1,NULL);
return eFail;
}
err = cpNode->resetChild();
pConsole->
writeStdout(
"resetChild() failed [ %1$ ]\n",&args[0],1,NULL);
return err;
}
pConsole->
writeStdout(
"nextChild() failed [ %1$ ]\n",&args[0],1,NULL);
return err;
}
err = cpChild->getValue( &pString, &length );
pConsole->
writeStdout(
"getValue() failed [ %1$ ]\n",&args[0],1,NULL);
return err;
}
retval = -1;
err = cpStr->wstrncmp(
P6CTEXT(
"5"), pString, 1, &retval );
if (0 != retval) {
pConsole->
writeStdout(
"Error: expected [ 5 ] but got [ %1$ ]\n",&args[0],1,NULL);
return eFail;
}
}
err = cpXPath->compileExpression(
P6CTEXT(
"/table/self::@style"), 19, NULL );
err = cpXPath->eval( cpDOM, NULL, NULL, &result );
{
err = cpNode->getName( &pString, &length );
pConsole->
writeStdout(
"getName() failed [ %1$ ]\n",&args[0],1,NULL);
return err;
}
retval = -1;
err = cpStr->wstrncmp(
P6CTEXT(
"style"), pString, 5, &retval );
if (0 != retval) {
pConsole->
writeStdout(
"Error: expected [ style ] but got [ %1$ ]\n",&args[0],1,NULL);
return eFail;
}
err = cpNode->resetChild();
pConsole->
writeStdout(
"resetChild() failed [ %1$ ]\n",&args[0],1,NULL);
return err;
}
pConsole->
writeStdout(
"nextChild() failed [ %1$ ]\n",&args[0],1,NULL);
return err;
}
err = cpChild->getValue( &pString, &length );
pConsole->
writeStdout(
"getValue() failed [ %1$ ]\n",&args[0],1,NULL);
return err;
}
retval = -1;
err = cpStr->wstrncmp(
P6CTEXT(
"background-color:purple"), pString, 23, &retval );
if (0 != retval) {
pConsole->
writeStdout(
"Error: expected [ background-color:purple ] but got [ %1$ ]\n",&args[0],1,NULL);
return eFail;
}
}
err = cpDOM->output( cpOutStream1, P6DOMOUTPUT_XML );
err = cpDOM->output( cpOutStream2, P6DOMOUTPUT_JSONML );
pConsole->
writeStdout(
"ERROR: Example failed with [ %1$ ]\n", &args[0], 1, NULL );
}
return err;
}
}
int main(int argc,char *argv[])
{
err = runDOM( cpConsole, cpDebugStream );
cpConsole->writeStdout("runDOM result: [ %1$ ]\n",&args[0],1,NULL);
cpConsole = NULL;
}
else printf("ERROR: Failed to retrieve console interface [ %x ]\n", err );
}
else printf("ERROR: Failed to initialize the loader [ %x ]\n", err );
}
else printf( "ERROR: Failed to create CConsoleStream [ %x ]\n", err );
return err;
}