On 7/24/2010 2:44 AM, Richard Webb wrote:
Hi,
I'm trying to execute a stylesheet without an XML source document using a named
template as the entry point of the stylesheet.
I'm trying to work my way through the Xalan-C++ Doxygen API reference and
samples for some examples, so far to no avail.
Can anybody on the list point me in the direction of some sample code or
appropriate API function in the documentation?
When you say "XML source document," I'm going to assume you mean a
source document to transform, not the XML document for the stylesheet.
Given that, you would need at least a trivial source document with a
single element, because the processor needs at least that to operate.
As for starting the execution of the stylesheet from a named template,
there is no facility to do that. The processor needs to perform basic
setup and there's no way to execute that code, then start with a
particular named template.
An easy way to simulate this would be to create a small stylesheet that
imports your stylesheet and have a single template that calls your named
template:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:import href="my-stylesheet.xsl" />
<xsl:template match="/">
<xsl:call-template name="my-template"/>
</xsl:template>
</xsl:stylesheet>
If you need to do this dynamically, you could trivially generate this
stylesheet in memory, then transform from that memory buffer.
I hope that helps.
Dave