tag:blogger.com,1999:blog-1294685061820866959.post8318304344195197755..comments2023-06-20T02:15:30.516+12:00Comments on Random.GetBlogEntry(): Transforming an XML file with an XSLT in PowerShellnzbarthttp://www.blogger.com/profile/08094173580905711110noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-1294685061820866959.post-72024649043613371932014-03-15T07:21:44.589+13:002014-03-15T07:21:44.589+13:00Ignore my comment on XSLT 2.0 - I re-read yours an...Ignore my comment on XSLT 2.0 - I re-read yours and notice that you're already aware of these issues.<br /><br />I also tried running my example repeatedly, and there was no problem:<br /><br />1..100 | % { $xslt = new-object system.xml.xsl.xslcompiledtransform;$xslt.load('c:\temp\xsl\transform.xslt');$xslt.Transform('c:\temp\xsl\input.xml', 'c:\temp\xsl\output.xml') }<br /><br />I also tried:<br /><br />$xslt = new-object system.xml.xsl.xslcompiledtransform; 1..100 | % { $xslt.load('c:\temp\xsl\transform.xslt');$xslt.Transform('c:\temp\xsl\input.xml', 'c:\temp\xsl\output.xml') }<br /><br />Again, no issues.nzbarthttps://www.blogger.com/profile/08094173580905711110noreply@blogger.comtag:blogger.com,1999:blog-1294685061820866959.post-85390323368140596242014-03-15T07:14:31.000+13:002014-03-15T07:14:31.000+13:00Interesting. I just tried a basic transform on Win...Interesting. I just tried a basic transform on Windows 8.1 and it worked as expected. This is what I did:<br /><br />1. Downloaded the XSLT and XML input data from this StackOverflow question (there's nothing special about this question - it just has a simple transform and input): https://stackoverflow.com/questions/4943611/simple-xslt-template<br />2. Ran the commands above - but with absolute paths like you have because the process's current working directory was different from the PowerShell current working directory<br /><br />The transformation worked as expected.<br /><br />Are you able to post the XSLT somewhere? Note that .NET unfortunately doesn't support XSLT 2.0, so it may be having trouble parsing your XSLT.nzbarthttps://www.blogger.com/profile/08094173580905711110noreply@blogger.comtag:blogger.com,1999:blog-1294685061820866959.post-90387006659046675452014-03-15T00:55:52.385+13:002014-03-15T00:55:52.385+13:00I'm trying your example, along with several ot...I'm trying your example, along with several others, under Windows 8.1 and I consistently get the following error. Has this call changed in the latest revision of code? I must have gone through about 10 various example code bodies and they all result in the exact same error it appears. I've Googled this error for hours and have found references noting that I can't use XSL 2.0 and other references to how the XSL might have includes or imports... but none of those apply to my simple example. Another post notes that it might be caused when running the example repeatedly as it should only be compiled once, but there wasn't any clear note regarding how to avoid compiling it more than once if the xslcompiledtransform object clearly has to be declared in order to be used. Any help would be appreciated. Apparently I am missing something basic here.<br /><br />CODE:<br />------------------<br />$xslt = new-object system.xml.xsl.xslcompiledtransform<br />$xslt.load('C:\Users\RJLyders\SkyDrive\Documents\ps1\cdcatalog.xsl')<br />$xslt.Transform('C:\Users\RJLyders\SkyDrive\Documents\ps1\cdcatalog.xml', 'C:\Users\RJLyders\SkyDrive\Documents\ps1\cdcatalog-out.xml')<br /><br />ERRORS:<br />----------------------- <br />Exception calling "Load" with "1" argument(s): "XSLT compile error."<br />At C:\Users\Jim\SkyDrive\Documents\ps1\xlst_transform.ps1:2 char:1<br />+ $xslt.load('C:\Users\Jim\SkyDrive\Documents\ps1\cdcatalog.xsl')<br />+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br /> + CategoryInfo : NotSpecified: (:) [], MethodInvocationException<br /> + FullyQualifiedErrorId : XslLoadException<br /> <br />Exception calling "Transform" with "2" argument(s): "No stylesheet was loaded."<br />At C:\Users\Jim\SkyDrive\Documents\ps1\xlst_transform.ps1:3 char:1<br />+ $xslt.Transform('C:\Users\Jim\SkyDrive\Documents\ps1\cdcatalog.xml', 'C:\Us ...<br />+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br /> + CategoryInfo : NotSpecified: (:) [], MethodInvocationException<br /> + FullyQualifiedErrorId : InvalidOperationException<br /> rjlydershttps://www.blogger.com/profile/04901150260187423944noreply@blogger.com