creating a copy of .rels files using SDK RRS feed

  • Question

  • Creating copies of package parts using the SDK is easily done by using a uri to get the source part and the CreatePart method to get the destination part and then calling the GetStream method of the source and destination parts to perform the copy.  Can this same technique be used to create copies of the .rels files?  If not, is the CreateRelationship method of a destination part a viable way of creating a .rels file for the part?  If so, how is it used?
    Thursday, June 21, 2007 9:26 PM

All replies

  • A relationship is not a part, so it could not be copied using the method you've described.

    CreateRelationship is an internal method so I don't think you could use it in your program.

    OpenXmlPartContainer.AddExternalRelationship() creates a relationship pointing to an external part;

    For an internal part, method OpenXmlPartContainer.AddPart<T> is designed to create a relationship pointing to an existing part of type 'T'; and OpenXmlPartContainer.AddNewPart<T> is designed to create a new part of type 'T' and a new relationship to the newly create part.

    The AddxxxPart() on the individual strong typed part class is similiar to AddNewPart<T>; only the method is restricted to the type of the part to be added.


    Monday, June 25, 2007 2:08 AM
  • The Packaging API where the SDK is based on actually does allow you to open a .RELS file as a PackagePart. Perhaps the SDK also has something similar.


    Eg, you can do a PackagePart relsPart = package.GetPart(new Uri("/_rels/.rels", UriKind.Relative)) and get the main relationship part.



    Tuesday, June 26, 2007 9:27 AM
  • I have a similar issue, Where i want to copy a given pair of slideX.xml( & .xml.rels), and its layout (slideLayoutX.xml and .rels). Using the AddNewPart method, and feeding it the same data from the original part works well enough for duplicating the parts, But i can't seem to duplicate the .rels files in any way.


    Is there a way to do this with the SDK or should i brute-force it somehow (Packaging API, or even resort to unzipping, copying files around, and zipping the package back)


    (Note: I figured the topic is similar enough and an answer would be relevant to the OP, so i posted it here.)


    Wednesday, February 20, 2008 10:14 AM