You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Inclusion of objects that are external to the exchange XML document #18
I have verified that I am running the latest version of the ReqIFSharp
I have searched open and closed issues to ensure it has not already been reported
Description
Currently the library does not provide support for extracting OLE objects or other objects that may be present in q reqifz file. This needs to be implemented. Question is what would be the best way to achieve this? Currently the reqif xml data is loaded into memory and a fully deserialized object graph is created and made available.
It doubt this is the best way forward for attachments. These might be large objects for which it does not make sense to load them into memory. Probably better to retrieve them (load via stream) on request.
Steps to Reproduce
NA
System Configuration
ReqIFSharp version:
ReqIFSharp: 3.0.1
Environment (Operating system, version and so on):
@LBRNZ can you let me know what kind of API would help you most for exposing objects? In case an external object is present, would you want to get it on request as a stream?
I created a fork and added this class: https://github.com/LBRNZ/reqifsharp_plus/blob/development/ReqIFSharp/EmbeddedObject.cs So i load every attached file into a memory stream and with the full name i can easily access them from the xhtml objects. My intention was that the files could not be manipulated once the reqif is loaded. The List of embeddedObjects is stored on the top level of the reqif:
/// <summary>
/// Backing field for the <see cref="EmbeddedObjects"/> property.
/// </summary>
private readonly List<EmbeddedObject> embeddedObjects = new List<EmbeddedObject>();
/// <summary>
/// Gets the optional preview images referenced in XHTML Attribute Values.
/// </summary>
[XmlIgnore]
public List<EmbeddedObject> EmbeddedObjects
{
get
{
return this.embeddedObjects;
}
}
thanks for the feedback, i am working on something for reqifsharp now. I do think that the implementation you have in your fork does have a memory leak and are you not worried that you run into a memory issue? If you have large embedded objects that you load into memory there might be a performance hit at some point (swapping).
What i am about to implement is something called ExternalObject which is the terminology used in the OMG spec with the 4 properties the spec states (data, type, width, height). The data property is a URI that (relative or absolute) that can be use to load the object from the reqifz file or from another resource in case of an absolute URI which could be something like http://www.example.com/bar.mp3.
I don't think intepreting the object is the responsibility of reqifsharp. with the uri and the type (mime-type) property a consuming app can work with it.
Yes I also noticed that problem already, but due to me not beeing an expert at all in these things :-) I have no Idea on how to dispose the MemoryStream after the file is unloaded. When I wrap it into a using command, the MemoryStream is already closed right after loading the file. Maybe I have to do a little research on this problem.
But I think your approach is a good one. You just have to give the user a handle to the file and he is responsible to interpret it
@LBRNZ i just created a pull request with a solution to read external objects. Can you have a look and let me know what you think? next step is to also support writing files to a reqifz file
@LBRNZ just released nuget version 3.1.0 which provides support for so-called External Objects.
The AttributeValueXHTML class now has a property called ExternalObjects that is a list of ExternalObjects found in the XHTML. The ExternalObject class exposes a method to determine whether the contents of the ExternalObject should be in the reqifz file or whether they are an external resource (http://www.somurl.org/image.png) that can be download using an httpclient.
use the IsDataLocal method to find out whether it is local or not.
in case it is local use the QueryLocalData method to extract the data, this method takes a Stream as argument which is populated with the content.
Looks nice so far. I have to check if I can make it work with the html renderer I use, because it only gives me the url of the embedded png. So I would have to somehow search all Specobjects and its Attributes to find the external object. Thats why I created a global List of external objects. Another issue I see is that it only works with reqifz and not with reqif and a folder of files
Activity
samatstariongroup commentedon Jun 16, 2021
@LBRNZ can you let me know what kind of API would help you most for exposing objects? In case an
externalobject is present, would you want to get it on request as a stream?LBRNZ commentedon Jun 16, 2021
I created a fork and added this class: https://github.com/LBRNZ/reqifsharp_plus/blob/development/ReqIFSharp/EmbeddedObject.cs So i load every attached file into a memory stream and with the full name i can easily access them from the xhtml objects. My intention was that the files could not be manipulated once the reqif is loaded. The List of embeddedObjects is stored on the top level of the reqif:
samatstariongroup commentedon Jun 16, 2021
thanks for the feedback, i am working on something for reqifsharp now. I do think that the implementation you have in your fork does have a memory leak and are you not worried that you run into a memory issue? If you have large embedded objects that you load into memory there might be a performance hit at some point (swapping).
I think the memory leak might appear here: https://github.com/LBRNZ/reqifsharp_plus/blob/6ca103694a5bfb92dbe547df8cda934ab841a760/ReqIFSharp/ReqIFDeserializer.cs#L206
What i am about to implement is something called
ExternalObjectwhich is the terminology used in the OMG spec with the 4 properties the spec states (data, type, width, height). The data property is a URI that (relative or absolute) that can be use to load the object from the reqifz file or from another resource in case of an absolute URI which could be something likehttp://www.example.com/bar.mp3.I don't think intepreting the object is the responsibility of reqifsharp. with the uri and the type (mime-type) property a consuming app can work with it.
LBRNZ commentedon Jun 16, 2021
Yes I also noticed that problem already, but due to me not beeing an expert at all in these things :-) I have no Idea on how to dispose the MemoryStream after the file is unloaded. When I wrap it into a using command, the MemoryStream is already closed right after loading the file. Maybe I have to do a little research on this problem.
But I think your approach is a good one. You just have to give the user a handle to the file and he is responsible to interpret it
samatstariongroup commentedon Jun 16, 2021
@LBRNZ i just created a pull request with a solution to read external objects. Can you have a look and let me know what you think? next step is to also support writing files to a reqifz file
find the PR here: #19
[Add] ExternalObject class to provide the capability to access extern…
samatstariongroup commentedon Jun 18, 2021
@LBRNZ just released nuget version 3.1.0 which provides support for so-called
External Objects.The
AttributeValueXHTMLclass now has a property calledExternalObjectsthat is a list of ExternalObjects found in the XHTML. TheExternalObjectclass exposes a method to determine whether the contents of the ExternalObject should be in the reqifz file or whether they are an external resource (http://www.somurl.org/image.png) that can be download using an httpclient.IsDataLocalmethod to find out whether it is local or not.QueryLocalDatamethod to extract the data, this method takes aStreamas argument which is populated with the content.here you can find a test method that demonstrates how it should be used https://github.com/RHEAGROUP/reqifsharp/blob/ed80b983aeb903fee1aa6ad99141fd131ac7d400/ReqIFSharp.Tests/ReqIFDeSerializerTestFixture.cs#L132
Please let me know what you think and whether this works for you
LBRNZ commentedon Jun 18, 2021
Looks nice so far. I have to check if I can make it work with the html renderer I use, because it only gives me the url of the embedded png. So I would have to somehow search all Specobjects and its Attributes to find the external object. Thats why I created a global List of external objects. Another issue I see is that it only works with reqifz and not with reqif and a folder of files