locked
Tag id corrupts Document RRS feed

  • Question

  • Hello,

    I generate word document from a software component but if i open in word this docx , word wanr me thet this is corrupted. Open the document.xml i have seen this code :

    <w:hyperlink r:id="rId9"> <w:r> <w:t>http://www.example.com</w:t> </w:r> </w:hyperlink>

    deleting tag solve the problem. I would like to understand what's the tag that is inserted or perhaps refers to a style that I inadvertently inserted? Thanks

    r:id="rId9"




    • Edited by first100 Tuesday, January 26, 2016 1:39 PM Code simplification
    Thursday, January 21, 2016 4:23 PM

Answers

  • Hi,

    Here is the description for this attribute:

    Specifies the ID of the relationship whose target shall be used as the target for this hyperlink.

    If this attribute is omitted, then there shall be no external hyperlink target for the current hyperlink - a location in the current document can still be target via the anchor attribute. If this attribute exists, it shall supersede the value in the anchor attribute.

    [Example: Consider the following WordprocessingML fragment for a hyperlink:

    <w:hyperlink r:id="rId9"> <w:r> <w:t>http://www.example.com</w:t> </w:r> </w:hyperlink>

    The id attribute value of rId9 specifies that relationship in the associated relationship part item with a corresponding Id attribute value must be navigated to when this hyperlink is invoked. For example, if the following XML is present in the associated relationship part item:

    <Relationships xmlns=""> <Relationship Id="rId9" Mode="External" Target=http://www.example.com /> </Relationships>

    The target of this hyperlink would therefore be the target of relationship rId9 - in this case, http://www.example.com. end example]

    The possible values for this attribute are defined by the ST_RelationshipId simple type (22.8.2.1).

    You can get more detail about this Hyperlink Class from link below:

    Hyperlink Class

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, January 22, 2016 1:44 AM
  • Hi,

    Did you want to remove this attribute using Open XML? If I understood correctly, we can using Hyperlink.RemoveAttribute to remove the specific attribute and here is an example for your reference:

     string filepath = @"C:\doc.docx";
                using (WordprocessingDocument doc = WordprocessingDocument.Open(filepath, true))
                {
                    foreach (Hyperlink hlink in doc.MainDocumentPart.Document.Descendants<Hyperlink>())
                    {
                        hlink.RemoveAttribute("id", "http://schemas.openxmlformats.org/officeDocument/2006/relationships");
                    }
                        
                }
    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, January 28, 2016 6:42 AM

All replies

  • Hi,

    Here is the description for this attribute:

    Specifies the ID of the relationship whose target shall be used as the target for this hyperlink.

    If this attribute is omitted, then there shall be no external hyperlink target for the current hyperlink - a location in the current document can still be target via the anchor attribute. If this attribute exists, it shall supersede the value in the anchor attribute.

    [Example: Consider the following WordprocessingML fragment for a hyperlink:

    <w:hyperlink r:id="rId9"> <w:r> <w:t>http://www.example.com</w:t> </w:r> </w:hyperlink>

    The id attribute value of rId9 specifies that relationship in the associated relationship part item with a corresponding Id attribute value must be navigated to when this hyperlink is invoked. For example, if the following XML is present in the associated relationship part item:

    <Relationships xmlns=""> <Relationship Id="rId9" Mode="External" Target=http://www.example.com /> </Relationships>

    The target of this hyperlink would therefore be the target of relationship rId9 - in this case, http://www.example.com. end example]

    The possible values for this attribute are defined by the ST_RelationshipId simple type (22.8.2.1).

    You can get more detail about this Hyperlink Class from link below:

    Hyperlink Class

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, January 22, 2016 1:44 AM
  • Thanks for reply

    How i can delete only tag and his attribute? 

     r:id="rId9"


    www.Photoballot.net

    Tuesday, January 26, 2016 1:46 PM
  • Hi,

    Did you want to remove this attribute using Open XML? If I understood correctly, we can using Hyperlink.RemoveAttribute to remove the specific attribute and here is an example for your reference:

     string filepath = @"C:\doc.docx";
                using (WordprocessingDocument doc = WordprocessingDocument.Open(filepath, true))
                {
                    foreach (Hyperlink hlink in doc.MainDocumentPart.Document.Descendants<Hyperlink>())
                    {
                        hlink.RemoveAttribute("id", "http://schemas.openxmlformats.org/officeDocument/2006/relationships");
                    }
                        
                }
    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, January 28, 2016 6:42 AM