Reputation: 7790
the xsl code is the following
<xsl:template match="/">
<xsl:for-each select="/t:Flow/t:AccountingRecords/t:AccountingRecord">
<xsl:result-document method="xml" href="UBL-invoice.2.1-{t:Reference}-output.xml">
<xsl:apply-templates select="."/>
</xsl:result-document>
</xsl:for-each>
</xsl:template>
this runs well from the command line using transform
now I try do use it from a .net app and I get the following error:
$exception {"The system identifier of the principal output file is unknown"} Saxon.Api.DynamicError
If I change my code to
<xsl:result-document method="xml" href="file:///d:/temp/UBL-invoice.2.1-{t:Reference}-output.xml">
<xsl:apply-templates select="."/>
</xsl:result-document>
then I get my files.
My question is: is there a way to work with relative path from an app, or must I add a dir parameter to my xsl ?
My code is quite the one from the samples
Processor proc = new Processor();
var comp = proc.NewXsltCompiler();
Xslt30Transformer exe = comp.Compile(new Uri("file:///" + System.IO.Path.GetFullPath("./Styles/style.xslt"))).Load30();
DocumentBuilder builder = proc.NewDocumentBuilder();
builder.BaseUri = new Uri("file:///" + System.IO.Path.GetFullPath("./ar2.xml"));
XdmNode inp = builder.Build(System.IO.File.OpenRead(System.IO.Path.GetFullPath("./ar2.xml")));
Serializer serializer = proc.NewSerializer();
serializer.SetOutputWriter(Console.Out);
// Transform the source XML and serialize the result document
exe.ApplyTemplates(inp, serializer); // < ==== Exception here
Upvotes: 1
Views: 530
Reputation: 163262
Set the BaseOutputURI
property on the Xslt30Transformer
object. This will be used as the base URI for resolving the relative URI appearing in xsl:result-document/@href
.
Upvotes: 1