Skip to content

Instantly share code, notes, and snippets.

View ond1's full-sized avatar

O'Neil Delpratt ond1

View GitHub Profile
@ond1
ond1 / testXSLT30.cpp
Last active July 25, 2023 17:54
SaxonC: C++ Samples for XSLT 3.1
#include <sstream>
#include <stdio.h>
#include "../../Saxon.C.API/DocumentBuilder.h"
#include "../../Saxon.C.API/SaxonProcessor.h"
#include "../../Saxon.C.API/XdmArray.h"
#include "../../Saxon.C.API/XdmFunctionItem.h"
#include "../../Saxon.C.API/XdmItem.h"
#include "../../Saxon.C.API/XdmMap.h"
@ond1
ond1 / testXQuery.cpp
Last active July 25, 2023 17:53
SaxonC: C++ Samples for XQuery
#include "../../Saxon.C.API/SaxonProcessor.h"
#include "../../Saxon.C.API/XdmArray.h"
#include "../../Saxon.C.API/XdmAtomicValue.h"
#include "../../Saxon.C.API/XdmFunctionItem.h"
#include "../../Saxon.C.API/XdmItem.h"
#include "../../Saxon.C.API/XdmMap.h"
#include "../../Saxon.C.API/XdmNode.h"
#include "../../Saxon.C.API/XdmValue.h"
#include "CppTestUtils.h"
@ond1
ond1 / testXPath.cpp
Created July 25, 2023 17:53
SaxonC: C++ Samples for XPath
#include "../../Saxon.C.API/SaxonProcessor.h"
#include "../../Saxon.C.API/XdmItem.h"
#include "../../Saxon.C.API/XdmNode.h"
#include "../../Saxon.C.API/XdmValue.h"
#include "CppTestUtils.h"
#include <string>
using namespace std;
// Test case on the evaluate method in XPathProcessor. Here we test that we have
@ond1
ond1 / testValidator.cpp
Created July 25, 2023 17:55
SaxonC: C++ sample for XML Schema Validator
#include "../../Saxon.C.API/SaxonProcessor.h"
#include "../../Saxon.C.API/XdmNode.h"
#include "../../Saxon.C.API/XdmValue.h"
#include "CppTestUtils.h"
#include <string>
using namespace std;
void testValidator1(SaxonProcessor *processor, SchemaValidator *val,
@ond1
ond1 / test_saxonc.py
Created July 25, 2023 18:00
SaxonC Python pyunit tests
from tempfile import mkstemp
import pytest
from saxonc@@edition@@ import *
import os
from os.path import isfile
from datetime import datetime as date
@pytest.fixture
def saxonproc():
@ond1
ond1 / testXSLT.c
Last active July 25, 2023 22:21
SaxonC C Sample for XSLT 3.0
#include <stdio.h> /* defines FILENAME_MAX */
#if defined(__APPLE__) || defined __linux__
#include <unistd.h>
#define GetCurrentDir getcwd
#else
#include <direct.h>
#define GetCurrentDir _getcwd
#endif
#include "../../Saxon.C.API/SaxonCProcessor.h"
@ond1
ond1 / testXQuery.c
Created July 25, 2023 22:21
SaxonC C Sample for XQuery 3.1
#include "../../Saxon.C.API/SaxonCProcessor.h"
#include <stdio.h> /* defines FILENAME_MAX */
#if defined(__APPLE__) || defined __linux__
#include <unistd.h>
#define GetCurrentDir getcwd
#else
#include <direct.h>
#define GetCurrentDir _getcwd
#endif
@ond1
ond1 / testXPath.c
Created July 25, 2023 22:22
SaxonC C Sample for XPath 3.1
#include "../../Saxon.C.API/SaxonCXPath.h"
#include <stdio.h> /* defines FILENAME_MAX */
#if defined(__APPLE__) || defined __linux__
#include <unistd.h>
#define GetCurrentDir getcwd
#else
#include <direct.h>
#define GetCurrentDir _getcwd
#endif
@ond1
ond1 / build-windows.sh
Last active July 26, 2023 08:23
SaxonC samples build script for C++
set graalvmdir=..\..\Saxon.C.API\graalvm
cl /EHsc "-I%graalvmdir%" testXPath.cpp ../../Saxon.C.API/SaxonCGlue.c ../../Saxon.C.API/SaxonCXPath.c ../../Saxon.C.API/SaxonProcessor.cpp ../../Saxon.C.API/XdmValue.cpp ../../Saxon.C.API/XdmItem.cpp ../../Saxon.C.API/XdmAtomicValue.cpp ../../Saxon.C.API/DocumentBuilder.cpp ../../Saxon.C.API/XdmNode.cpp ../../Saxon.C.API/XdmFunctionItem.cpp ../../Saxon.C.API/XdmArray.cpp ../../Saxon.C.API/XdmMap.cpp ../../Saxon.C.API/SaxonApiException.cpp ../../Saxon.C.API/XQueryProcessor.cpp ../../Saxon.C.API/Xslt30Processor.cpp ../../Saxon.C.API/XsltExecutable.cpp ../../Saxon.C.API/XPathProcessor.cpp ../../Saxon.C.API/SchemaValidator.cpp /link ..\..\libs\win\libsaxon-@@edition@@c-@@VERSION@@.lib
cl /EHsc "-I%graalvmdir%" testXSLT30.cpp ../../Saxon.C.API/SaxonCGlue.c ../../Saxon.C.API/SaxonCXPath.c ../../Saxon.C.API/SaxonProcessor.cpp ../../Saxon.C.API/XdmValue.cpp ../../Saxon.C.API/XdmItem.cpp ../../Saxon.C.API/XdmAtomicValue.cpp ../../Saxon.C.API/DocumentBuilder.cpp ../../Saxo
@ond1
ond1 / testXSLT30.cpp
Last active July 26, 2023 08:30
SaxonC C++ API sample
SaxonProcessor * saxonProc = new SaxonProcessor(true);
try {
proc->setCatalog("../data/catalog.xml");
Xslt30Processor *trans = saxonProc->newXslt30Processor();
XsltExecutable *executable = trans->compileFromFile("../data/example.xsl");
executable->setInitialMatchSelectionAsFile("../data/example.xml");
const char *result = executable->applyTemplatesReturningString();
if (result != NULL) {
std::cerr << "result= " << result << std::endl;