[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Saxon Process is not releasing my output file

Subject: Saxon Process is not releasing my output file
From: "Spencer Tickner" <spencertickner@xxxxxxxxx>
Date: Sun, 10 Dec 2006 09:33:14 -0800
 Saxon Process is not releasing my output file
Hi List,

Hope this is an "in Scope" question. I'm using Saxon to run a process
in .net. The basic scenario is my xslt takes an XML called new,
compares it to an XML document called old. Then the "new" XML document
is copied over "old".

The problem is when the copy happens I get the dreaded "The process
cannot access the file 'L:\file_path\old.xml' because it is being used
by another process".

The call:

Dim x As New Saxon
x.Transform(strDir & "my.xsl", strDir & "new.xml", strRepository &
"difference.xml")
x = Nothing

' Error occurs here
File.Copy(strDir & "Stat.xml", strDir & "stat_old.xml", True)


The Transform: (probably more Nothing/Flush/Close commands then I need but I wanted to make sure everything was taken care of):

      Public Sub Transform(ByVal xslDoc As String, ByVal xmlDoc As String, _
           ByVal output As String)


Dim u As Uri 'Create a New Processor instance Dim processor As New Processor 'Load the source document u = New Uri(xmlDoc) Dim input As XdmNode = processor.NewDocumentBuilder.Build(u) 'Create the transformer for the stylesheet Dim transformer As XsltTransformer

           Try
               u = New Uri(xslDoc)

               transformer = _
                   processor.NewXsltCompiler().Compile(u).Load()
           Catch ex As Exception
               u = Nothing
               MsgBox("Exception" & ex.ToString)
               MsgBox(ex.StackTrace)
               Throw New Exception(ex.Message)
           End Try

           'Set the root node of the source document to be the
initial context node
           transformer.InitialContextNode = input

           'Create the serializer
           Dim serializer As New Serializer
           Dim fi As FileStream
           Try
               fi = New FileStream(output, FileMode.Create, FileAccess.Write)
               serializer.SetOutputStream(fi)
               'Transform the source XML
               transformer.Run(serializer)
               'fi.Flush()
               'fi.Dispose()
               fi.Close()
           Catch ex As Exception
               Throw New Exception(ex.Message)
           Finally
               u = Nothing
               serializer = Nothing
               transformer = Nothing
               processor = Nothing
               input = Nothing
               fi = Nothing
           End Try

End Sub

Thanks for any help..

Spencer

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.