I am trying to split output into multiple file by using xsl:result-document. But not sure how to store the split result in Azure, FTP and SFTP server.
Input XML:
<ArrayOfBatch>
<Batch>
<BatchName>BatchName-1</BatchName>
</Batch>
<Batch>
<BatchName>BatchName-2</BatchName>
</Batch>
<Batch>
<BatchName>BatchName-3</BatchName>
</Batch>
</ArrayOfBatch>
XSLT Format:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" version="3.0" exclude-result-prefixes="fn xs">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<xsl:for-each select="/ArrayOfBatch/Batch">
<xsl:result-document href="Batch-{position()}.xml" >
<xsl:copy-of select="*"/>
</xsl:result-document>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
c# code:
public static string SaxonProcessorXSLT(string xmlToExport, string xslStylesheet)
{
using (StringReader xmlStream = new StringReader(xmlToExport))
{
using (StringReader xslStream = new StringReader(xslStylesheet))
{
Processor xsltProcessor = new Processor();
DocumentBuilder documentBuilder = xsltProcessor.NewDocumentBuilder();
documentBuilder.BaseUri = new Uri("file://");
XdmNode xdmNode = documentBuilder.Build(xmlStream);
XsltCompiler xsltCompiler = xsltProcessor.NewXsltCompiler();
XsltExecutable xsltExecutable = xsltCompiler.Compile(xslStream);
XsltTransformer xsltTransformer = xsltExecutable.Load();
xsltTransformer.InitialContextNode = xdmNode;
xsltTransformer.BaseOutputUri = new Uri("D://home//data//");
using (StringWriter stringWriter = new StringWriter())
{
Serializer serializer = xsltProcessor.NewSerializer();
serializer.SetOutputWriter(stringWriter);
xsltTransformer.Run(serializer);
return stringWriter.ToString();
}
}
}
}
From the above code the result of split file is stored in local path "D://home//data8//" but I am looking for a solution to store this result in azure, FTP and SFTP server by using URI on xsltTransformer.BaseOutputUri.
I have done some R&D on this but its not solving my problem. Looking for quick response. Thanks in advance.