aboutsummaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
2014-06-08Handling xercesc::DOMException in "read-xml-file" and "external-text-formatter"Adrian Kummerländer
* external DOM may cause xercesc::DOMException's to be thrown instead of passing all errors to the custom error handlers ** these exceptions are handled by this commit by setting the "result" attribute to "error" and adding "error" value nodes with further information
2014-06-07Provided previously missing Sequence template implementationAdrian Kummerländer
* implemented for commit 5f6fc45 but not included into that commit
2014-06-07Improved FunctionBase constructDocument parameter propagationAdrian Kummerländer
* replaced std::tuple constructing Mapper template methods with direct XObjectArgVectorType unpacking ** XObjectValue::get template method is applied directly using parameter pack unpacking * implemented custom IndexSequence / Sequence type to provide vector indexes * modified all external functions to provide matching constructDocument overloads
2014-06-06Implemented WarningCapacitor as a counterpart to ErrorCapacitorAdrian Kummerländer
* in difference to ErrorCapacitor this class doesn't throw an exception on "discharge" but returns the gathered warnings * adapted FunctionTransform and frontend error handling to include warnings * added static "try_create" method to TransformationFacade ** wraps construction error handling ** custom logic may be embedded using the std::function argument *** this was implemented to prevent unneccessary code duplication for handling both construction and generation errors * adapted FunctionTransform to return warning as "warning" nodes in the result tree ** added functional lambda expression factory method "handleErrors" *** returns a error handling lambda expression for a given ResultNodeFacade * implemented WarningGuard class in frontend executable ** guarantees warnings to be printed to std::cerr independent of any exceptions
2014-06-05Implemented ErrorMultiplexer as primary error handlerAdrian Kummerländer
* ErrorMultiplexer is derived from both xercesc::ErrorHandler and xalan::ProblemListener * registers itself as XalanTransformer's ErrorHandler and ProblemListener * distributes captured errors and warnings to all registered ErrorMultiplexer::Receiver instances ** ErrorCapacitor implements the ErrorMultiplexer::Receiver interface and as such registers itself in a given ErrorMultiplexer instance ** ErrorMultiplexer reduces the different xalan and xercesc internal error classifications into either warnings or errors * this was implemented to make it possible to easily differentiate between warnings and errors ** previously warnings were treated as errors ** ErrorCapacitor ignores warnings and only captures errors ** WarningCapacitor will be implemented to handle warnings during XSLT processing
2014-06-03Replaced XSLTInputSource with LocalFileInputSource in "read-xml-file"Adrian Kummerländer
* removes xalan and boost::filesystem::fstream dependencies from FunctionReadXmlFile * xercesc provides a solution for loading files into it's XercesDOMParser class ** this should be used instead of building a custom replacement using boost's fstream and xalan::XSLTInputSource
2014-06-02Expanded ErrorCapacitor error message generationAdrian Kummerländer
* added entity, line and column information * formatting analog to ErrorCapacitor warning messages ** i.e. this commit implements functionality similar to "xalanc::ProblemListenerBase::defaultFormat" for "xercesc::ErrorHandler" exceptions
2014-05-31Revamped external function result treesAdrian Kummerländer
* the root node of the result tree of each function is a domain element ** i.e. the root node of "read-xml-file" is "file", the root node of "read-directory" is "directory" * the root node contains the result state of the function call encoded in a "result" attribute ** possible values are "success" and "error" ** the root node may contain additional attributes such as the target path of a called transformation * the actual function result is contained within the child nodes of the function root node ** i.e. the XML file tree returned by "read-xml-file" is a child of the function root node ** if specific errors occured they are also returned as child nodes of the function root node *** this is currently only the case for "transform" where transformation errors are returned as "error" value node childs of the function root node * updated test cases accordingly
2014-05-31Using xalan::ProblemListenerBase formatting functionality in ErrorCapacitorAdrian Kummerländer
* xalan::ProblemListenerBase provides a static member method called "defaultFormat" ** this method provides formatting of problem messages into xalan::XalanDOMString instances when combined with xalan::DOMStringPrintWriter * there is no need for implementing custom message formatting ** the only reason why ErrorCapacitor exists is so we are able to capture and print messages at our own volition
2014-05-30Rewrote error handling based on exceptionsAdrian Kummerländer
* ErrorHandler is replaced by ErrorCapacitor ** temporarily registers itself as both the ProblemListener and ErrorHandler of a given XalanTransformer instance ** deregisters itself on destruction ** collects all problems and errors during its lifetime inside a internal std::vector<std::string> instance ** if this instance is not empty it is thrown contained within a ErrorCapacitor::exception by the member method ErrorCapacitor::discharge * this enables using the same code for handling transformation compilation and generation errors and problems * updated test frontend accordingly
2014-05-29Fixed error handling of invalid XSL transformationsAdrian Kummerländer
* xalan is segfaulting in XalanDOMString constructor when the static member "XalanLocator::getSystemId" is returning null-pointer ** this should seemingly be handled by passing a pointer to the static constant m_dummy but this sadly fails to prevent the segfault ** the patch provided by this commit fixes the problem for now but I cannot guarantee that this wont cause any side effects in a other context * Adapted TransformationFacade to handle errors during transformation compilation ** errors generated during transformation compilation are returned through the generate member method ** throwing an exeception during TransformationFacade construction would require additional error handling in the calling code * Added xalan::ProblemListener functionality to the ErrorHandler class ** XSLT problems passed to the ProblemListener are returned alongside to and treated as all other transformation errors
2014-05-29Improved TransformationFacade error handlingAdrian Kummerländer
* ErrorHandler class created in 5859cb6 now caches all errors instead of pushing them to std::cerr ** cached errors are retrieved by TransformationFacade's "generate" member method * test frontend pushes all errors to std::cerr * FunctionTransform returns errors to the calling template as XML ** FunctionTransform test case demonstrates how one may test for successful transformation * "generate" member method returns std::string vector wrapped in a std::unique_ptr ** this is used as a kind of optional pointer, as the std::unique_ptr instance only wraps a vector if errors where actually generated
2014-05-28Moved input trimming into XObjectValue namespaceAdrian Kummerländer
* std::string specialization of "get" template method * replaces FunctionTransform local input trimming implemented in 5859cb6
2014-05-28Implemented basic ErrorHandlerAdrian Kummerländer
* InputXSLT::ErrorHandler is derived from xercesc::ErrorHandler and enables contextual printing of transformation errors ** currently this means that the error messages passed to std::cerr contain the full path of the offending transformation * added input trimming to the external transform function ** calls to this function from inside a transformation may contain unnecessary whitespace characters which disrupt further processing
2014-05-26Revamped external execute function into a external text formatter functionAdrian Kummerländer
* importing XML output of a called executable into the result document required special logic which clashed with a general execute function * general execute function may be implemented in the future ** support for external text formatters with XML output has a higher priority * current implementation enables calling a markdown parser and including the XHTML output into the document
2014-05-25Implemented basic external "execute" functionAdrian Kummerländer
* enables execution of external programs ** second parameter is passed to stdin ** stdout is captured and returned ** based on booost::process * this was implemented to enable access to external content preprocessors such as markdown
2014-05-24Prevented FilesystemContext from resolving absolute pathsAdrian Kummerländer
* there are situations where one may pass absolute paths to external functions which should not be resolved against the context path ** for example when reading files found by "read-directory" through its "full" value node * this could be checked by the external functions themself ** but as this check is required by all of them it is better implemented in the FilesystemContext
2014-05-24Implemented ResultNodeFacade as a DOM node construction helperAdrian Kummerländer
* wraps result node construction and appends it to root node on destruction * offers a simpler interface for common node construction patterns * simplifies result node construction in all external function implementations ** most noticeable in FunctionReadDirectory * expanded FunctionReadDirectory result nodes by name, extension, and full-path nodes
2014-05-23Changed iterate functor parameter to const referenceAdrian Kummerländer
* replaced ranged for loop with more appropriate std::for_each
2014-05-23Simplified IncludeEntityResolver constructor and improved constnessAdrian Kummerländer
* std::vector<FilesystemContext> instance is now const ** this required a constructor change * marked resolve member method as const as it doesn't need to modify anything ** this is also true for the overloaded resolveEntity member method ** the base class xercesc::EntityResolver prevents us from marking it as such
2014-05-22Replaced std::pair<bool, *> with the more convenient boost::optional<*>Adrian Kummerländer
* InputXSLT is dependent on boost anyway, so there is no argument to be made to emulate boost::optional using std::pair
2014-05-22Added include path resolution to external file access functionsAdrian Kummerländer
* if a given file can not be located relative to the transformation's location both "read-file" and "read-xml-file" will now try to resolve the path using the IncludeEntityResolver * all external functions based on the FunctionBase template are now provided with a pointer to a IncludeEntityResolver instance * it is determined by the external function implementation whether include path resolution will be used
2014-05-21Moved include path resolution into separate member methodAdrian Kummerländer
* enables access to include path resolution from external functions ** this will be useful to enable reading files from the include path using the external read-file or read-xml-file functions * moved file path extraction into a function local to the compilation unit
2014-05-20Replaced FunctionResolveInclude with IncludeEntityResolverAdrian Kummerländer
* xalan / xerces offers the possibility of implementing custom entity resolvers which are called upon by "<xsl:include..." ** such a custom resolver was implemented to resolve include path entities * this is a much better way to support include paths than offering a custom external "resolve-include" function * as entity paths are expanded before they are passed to the entity resolver, a special "[path]" syntax simmilar to "#include <path>" had to be implemented
2014-05-19Implemented external "resolve-include" functionAdrian Kummerländer
* resolves paths provided as strings against include paths provided through the newly created "--include" argument of the test executable * this was implemented to enable central collections of XSLT libraries simmilar to how there are C headers in "/usr/include"
2014-05-18Added possibility for streaming TransformationFacade outputAdrian Kummerländer
* added "std::basic_ostream<char>" taking "generate" member method overloads * marked cli parameter "target" as optional ** output is streamed to std::cout if target file is not provided
2014-05-17Equalized parameter/argument naming pattern accross all external functionsAdrian Kummerländer
* names matter, from now on parameters to external functions will be called parameters uniformly instead of mixing arguments and parameters
2014-05-16Added XObjectPtr parameter to FunctionTransformAdrian Kummerländer
* the given XObject is passed to the called transformation ** this was done to enable templates to pass information to each other ** this should support any type usable in a XPath context to be passed as an argument * expanded FunctionTransform test case accordingly
2014-05-15Adapted FunctionBase template to accept multiple argument typesAdrian Kummerländer
* FunctionBase::argument_tuple is a std::tuple specialization type specialized on the argument types passed inside the variadic template argument of FunctionBase * added tuple Mapper and XObjectValue helper namespaces containing recursive tuple construction and XObjectPtr value extraction logic * changed all external function implementations accordingly * this change was implemented to uniformly support different external function argument types than std::string
2014-05-14Moved responsibility for argument conversion to FunctionBase descendantsAdrian Kummerländer
* external functions may expect arguments with a type different from boost::filesystem::path so they are only provided raw string values * moved xalan string conversion logic into separate compilation unit
2014-05-14Added ArgumentCount parameter to FunctionBase templateAdrian Kummerländer
* constructDocument member method is provided with a FunctionBase::argument_array instance * improved argument validation in FunctionBase * this parameter was added to support FunctionBase as a base class for FunctionTransform
2014-05-13Sorting FilesystemContext iteration resultsAdrian Kummerländer
* order of items in a directory was varying across platforms which hindered testability * they are now temporarily copied into a std::vector instance and then sorted using std::sort * updated "read_directory" test case reference file accordingly
2014-05-12Implemented basic external transform functionAdrian Kummerländer
* "InputXSLT:transform" expects two input arguments and executes the given transformation into the given target file ** this function respresents a important step in the direction of making it possible to write an actual static site generator on top of InputXSLT using XSLT * added basic "transform" test case * updated README.md to include this new function
2014-05-11Switched internal DomDocumentCache structure to std::stackAdrian Kummerländer
* using std::unordered_map for named cache lookups was a nice idea but is not useful when one keeps in mind that: ** we don't want cached external function responses in a situation where we are able to execute transformations inside transformations ** cached responses mean that we can not read a xml file, overwrite it using another transformation and then read it again * the currently available InputXSLT frontend only processes a single transformation anyway, so increased memory requirements should not pose a problem ** if a future frontend should offer batch processing of transformation tasks, one could implement a cache reset method to free memory after a transformation has been processed
2014-05-10Implemented StylesheetParameterGuard classAdrian Kummerländer
* removes responsibility for clearing parameters from the generate member methods * abstracts parameter escaping and setting and handles map conversion * marked actual generate member method as private and added StylesheetParameterGuard reference argument ** "frontend" generate member methods instantiate a StylesheetParameterGuard instance and pass it to the actual generate method ** this enables central default parameter definition while offering the possibility for custom parameters
2014-05-09Added default target file and path parametersAdrian Kummerländer
* the transformation is now provided with default parameters such as the target file and its parent directory * added appropriate test case ** default_params * test frontend now doesn't provide a "test" parameter anymore * extracted parameter setter into separate member method "setParameters" of TransformationFacade
2014-05-09Marked DomDocumentCache::item class as privateAdrian Kummerländer
* as the xerces document is not instantiated by DomDocumentCache::item and the class only exports a pointer to the converted xalan document, it makes no sense to expose the class to the outside in the first place
2014-05-08Removed gtest based test cases and added program optionsAdrian Kummerländer
* selectively testing document construction in plain C++ code has turned out to be more work than worth it ** i.e. removed test cases and GTest dependency * added boost::program_options based frontent to InputXSLT ** example command: "./test --transformation ../dummy/transform.xsl --target out.xml" ** the plan is to use a simple shell script that generated test transformations and compares the output to reference files
2014-05-06Added basic external read file function test caseAdrian Kummerländer
* ... as a test of how well we are able to test DOM structures * required change of constructDocument visibility
2014-05-05Encapsulated common parts of external function inplementationsAdrian Kummerländer
* common parts were moved into CRTP template base class _FunctionBase_ * all external functions are derived from that class ** only have to implement _constructDocument_ member method ** currently only supports a single string input parameter which is enough for now * this change condenses external funtion implementations to the essential and should increase readability as well as maintainability
2014-05-04Moved DOM document construction logic into local functionsAdrian Kummerländer
* this change makes the underlying similarity between all currently implemented external functions obvious * they more or less only differ in their document construction logic ** i.e. there is a possibility for a second layer of abstraction between the classes derived from xalan::Function and the actual functionality * added boost::filesystem::path taking overload of the _iterate_ member method to FilesystemGuard ** this overload functions as the _master_ overload that is called by all other overloads which merely perform type conversion and path resolution ** this overload doesn't perform path resolution
2014-05-04Changed FilesystemContext constructor to accept xalan::Locator*Adrian Kummerländer
* all instantiations of a FilesystemContext are currently based on information provided by a xalan::Locator instance provided to the external function execute member method * this change hides the stylesheet path extraction from the actual function implementation
2014-05-03Revamped DomDocumentCache with regard to thread safetyAdrian Kummerländer
* DomDocumentCache::item class now is _finalized_ by default and doesn't perform document instantiation, just lifetime management ** xercesc::DOMDocument is instantiated inside the external function implementations and committed to the document cache for conversion to a xalan document * added mutex with scoped lock to prevent concurrent write access to the std::unordered_map contained withing DomDocumentCache * functionality of the _get_ member method was split into _get_ and _create_ ** added typedef for std::pair specialization type "optional_item" that functions as the return value of _create_ and _get_ * "locator->getSystemId()" was leaking memory as xerces doesn't manage the lifetime of the returned heap-allocated char array ** analog to XMLCh* strings ** transformed XercesStringGuard into template class to be instantiated on either XMLCh or char
2014-05-02Changed external functions to enable global installationAdrian Kummerländer
* up until now all external functions were locally installed to a specific XalanTransformer instance contained within a TransformationGuard instance ** this had to change as I planned to add a "execute-transformation" function based on TransformationGuard which would have led to recursive self-instantiation ** global external functions have to be thread-safe * as global external function can not be provided with a reference to a transformation-specific FilesystemFacade instance, the working path is now determined using xalan::Locator ** currently using pointer arithmetics on XMLCh* to remove the "file://" prefix of the URI returned by locator->getSystemId(), may be unsafe * added compilation unit for PlattformGuard as it now contains function installation in addition to plattform lifetime management
2014-05-01Added basic parameter taking overload of TransformationFacade::generateAdrian Kummerländer
* XSLT stylesheets may be provided with a set of initial parameters ** these parameters can be provided as the second argument to the generate member method in the form of a string to string mapping ** the XSLT standard also permitts number and node set types as value arguments of such input parameters but this is not supported by this change * expanded test transformation to demonstrate this feature
2014-05-01Changed namespace for external functions to InputXSLTAdrian Kummerländer
* "InputXSLT" is defined as "function.inputxslt.application" * functions can now be accessed like "InputXSLT:read-file('../')" * updated test transformation accordingly * the XML standard does not require namespaces to be real, valid HTTP-URIs but treats them as plain strings
2014-04-30Moved file reading functionality into local functionsAdrian Kummerländer
* it was moved into functions local to the respective compilation unit to improve readability ** splits DOM tree construction logic from the actual purpose of the external function
2014-04-29Simplified external function result node setAdrian Kummerländer
* all functions return a single "error" node in the case that something went wrong * otherwise they return one or more "result" nodes that contain the function results and may be distinguished by one or more attributes * this makes handling the return values easier and more pleasing to the eye as not everything has to be prefixed by "self::*" * updated test transformation accordingly
2014-04-28Adapted read-directory tree construction to match the other functionsAdrian Kummerländer
* throwing std::out_of_range exception from DomDocumentCache::get instead of returning nullptr in case of a problem * moved xalanToString method back into FilesystemContext compilation unit as is only needed there
2014-04-27Added status information to external read-xml-file functionAdrian Kummerländer
* XML tree is contained below the _content_ node if read was successful ** status is set to error otherwise * updated test transformation accordingly