0

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>

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();

var baseOutUri = new System.Uri(Directory.GetCurrentDirectory());
exe.BaseOutputURI = baseOutUri.AbsoluteUri;
Console.WriteLine(exe.BaseOutputURI);

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

The Console.WriteLine writes:

file:///D:/dev/fromSvn/cclb/bas/bin/debug

But the outputs are generated in:

D:\dev\fromSvn\cclb\bas\bin

If I want to fix this I have to modify my code to:

exe.BaseOutputURI = baseOutUri.AbsoluteUri + "/";

M'I correct or do I miss something ?

1 Answer 1

1

This is the way URI resolution works. If the base URI is /a/b/c, and the relative URI is w.xml, then the result of resolving the relative URI against the base URI is /a/b/w.xml. The algorithm for resolving a relative URI is a syntactic operation on two character strings, it never attempts to work out whether the base URI /a/b/c refers to a directory, to an ordinary file, or to nothing in particular.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.