Project

Profile

Help

document-uri gone when using Saxon.API .NET?

Added by Anonymous almost 18 years ago

Legacy ID: #3768422 Legacy Poster: eholley (eholley)

When using the .NET command line tool, transform.exe, document-uri is available in the XSL. However, when using the Saxon.API to transform files, the document-uri is blank. Here's my code: public static string Transform(string xml, string xsl, Uri xmlBaseUri, Uri xslBaseUri, NameValueCollection transParams) { // Load the source document DocumentBuilder builder = processor.NewDocumentBuilder(); builder.BaseUri = xmlBaseUri; Stream xmlStream = new MemoryStream(Encoding.UTF8.GetBytes(xml)); XdmNode input = builder.Build(xmlStream); xmlStream.Close(); // Compile the stylesheet XsltCompiler compiler = processor.NewXsltCompiler(); compiler.BaseUri = xslBaseUri; Stream xslStream = new MemoryStream(Encoding.UTF8.GetBytes(xsl)); XsltExecutable exec = compiler.Compile(xslStream); xslStream.Close(); // Create transformer with parameters XsltTransformer transformer = exec.Load(); foreach(string key in transParams.AllKeys) { transformer.SetParameter(new QName("", "", key), new XdmAtomicValue(transParams[key])); } // Run transformer.InitialContextNode = input; XdmDestination results = new XdmDestination(); transformer.Run(results); return results.XdmNode.StringValue; } public static string Transform(Uri xml, Uri xsl, NameValueCollection transParams) { // Load the source document DocumentBuilder builder = processor.NewDocumentBuilder(); XdmNode input = builder.Build(xml); // Compile the stylesheet XsltCompiler compiler = processor.NewXsltCompiler(); XsltExecutable exec = compiler.Compile(xsl); // Create transformer with parameters XsltTransformer transformer = exec.Load(); foreach(string key in transParams.AllKeys) { transformer.SetParameter(new QName("", "", key), new XdmAtomicValue(transParams[key])); } // Run transformer.InitialContextNode = input; XdmDestination results = new XdmDestination(); transformer.Run(results); return results.XdmNode.StringValue; }


Replies (1)

RE: document-uri gone when using Saxon.API .N - Added by Anonymous almost 18 years ago

Legacy ID: #3775440 Legacy Poster: Michael Kay (mhkay)

Thanks for pointing this out. I've raised a bug (with a source patch if needed) at https://sourceforge.net/tracker/index.php?func=detail&aid=1505250&group_id=29872&atid=397617 Michael Kay Saxonica

    (1-1/1)

    Please register to reply