Creating text-file and TextWriterDestination
Added by Anonymous almost 16 years ago
Legacy ID: #6022010 Legacy Poster: Andreas Rumsch (arumsch)
Hi I started working with Saxon-B (9.1.0.5) and try to migrate my code that used the System.Xml namespace in .NET. Now I've a problem when transforming with a xslt that has the xsl:out method="text": I use a TextWriterDestination with a XmlWriter: XmlWriter xmlWriter = XmlWriter.Create(filename); XmlDestination serializer = new TextWriterDestination(xmlWriter); ... loadedXslt.Run(serializer); The last line gives the error, that the resulting document would not result in a well formed Xml (of course, it's a plain text). In old code I initialized the XmlWriter this way: xsltTransformer = new XslCompiledTransform(false); XsltSettings settings = new XsltSettings(true, true); xsltTransformer.Load(xsltStream, settings, new XmlUrlResolver()); XmlWriter.Create(filename, xsltTransformer.OutputSettings); So I took the OutputSettings from the XslCompiledTransform. How can I do this with Saxon? Thanks
Replies (2)
RE: Creating text-file and TextWriterDestination - Added by Anonymous almost 16 years ago
Legacy ID: #6027118 Legacy Poster: Michael Kay (mhkay)
You can't do this very easily using the Saxon .NET API, but I think you can discover the output properties of the stylesheet if you dig deep enough: the Implementation property of the XsltTransformer gives you a net.sf.saxon.Controller, and this has a method getOutputProperties which returns a Properties object whose getProperty() method will return the relevant property.
RE: Creating text-file and TextWriterDestination - Added by Anonymous almost 16 years ago
Legacy ID: #6048041 Legacy Poster: Andreas Rumsch (arumsch)
Thank you. That helped me a lot. And it was rather easy to get the information and transfer it to a Setting-object.
Please register to reply