Project

Profile

Help

Are XML files opened as read-only?

Added by Anonymous about 15 years ago

Legacy ID: #7390117 Legacy Poster: Debbie Croft (debbiecroft)

When the Processer and/or XsltTransformer are being used to transform an XML source file, is that source file open as read-only, or is it opened with an exclusive lock for some reason? I'm experiencing a problem with an application that uses Saxon that might occur if the Saxon parser opened the source files with exclusive access, but I can't see why it would need to do that.


Replies (3)

Please register to reply

RE: Are XML files opened as read-only? - Added by Anonymous about 15 years ago

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

Are you on Java or .NET, as a matter of interest? My own experience is that I see this kind of problem more often on .NET - failing to close a file, in particular, seems to cause more problems on .NET. As a general point, Saxon doesn't usually open input files. You either do it yourself (by supplying an input stream), or the XML parser does it. So the devil here is in the detail. It depends on exactly what you are doing.

RE: Are XML files opened as read-only? - Added by Anonymous about 15 years ago

Legacy ID: #7390167 Legacy Poster: Debbie Croft (debbiecroft)

I'm using .NET. Here's a code snippet. I don't explicitly open the file (xmlFilePath). Uri sourceUri = new Uri(xmlFilePath); XdmNode source = f_processor.NewDocumentBuilder().Build(sourceUri); StringWriter target = new StringWriter(); Serializer serializer = new Serializer(); serializer.SetOutputWriter(target); f_transformer.InitialContextNode = source; f_transformer.Run(serializer); target.Close();

RE: Are XML files opened as read-only? - Added by Anonymous about 15 years ago

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

Thanks. In this scenario the URI is converted to a Stream by using the .NET XmlUriResolver class, and the resulting Stream is then passed to a .NET XmlTextReader. I'm afraid those two classes are pretty much black boxes to me. If you want more control you could nominate your own XmlResolver to be used instead, or of course you could use the overloaded Build method that takes a Stream as input.

    (1-3/3)

    Please register to reply