none
Add custom attributes to existing WordML elements RRS feed

  • Question

  • Hello,

    I would like to add custom attributes to my xslt generated WordML files. These attributes will be assigned to existing WordML elements and used later by other xslt files to further transform the files and their data. When I add attributes this way, after edits through the word UI are made and saved, the custom attributes get removed.

    <w:tr myCustomAttributeRecordNumber="1" wsp:rsidR="005D5AD2" wsp:rsidRPr="002D4099" wsp:rsidTr="00A5102B">
    <w:trPr><w:jc w:val="center" /></w:trPr> 
    	<w:tc myCustomAttributeColumnName="Item Name"> <w:tcPr> <w:vAlign w:val="center" /> </w:tcPr> 
    		<w:p wsp:rsidR="005D5AD2" wsp:rsidRPr="002D4099" wsp:rsidRDefault="005D5AD2" wsp:rsidP="00A5102B"> 
    			<w:pPr> <w:spacing w:before="60" w:after="60" /> <w:jc w:val="center" /> <w:rPr> <w:rFonts w:ascii="Arial" w:h-ansi="Arial" w:cs="Arial" /> <wx:font wx:val="Arial" /> <w:sz w:val="20" /> </w:rPr> </w:pPr> 
    				<w:r> <w:rPr> <w:rFonts w:ascii="Arial" w:h-ansi="Arial" w:cs="Arial" /> <wx:font wx:val="Arial" /> <w:sz w:val="20" /> </w:rPr> <w:t>Test Name</w:t> </w:r> 
    		</w:p> 
    	</w:tc> 
    </w:tr>   

    What is the appropriate method to include custom attributes that will be retained for the lifetime of the document?

    Thank you for your help.




    • Edited by paradisp Tuesday, May 31, 2011 3:39 PM code edit
    Tuesday, May 31, 2011 3:35 PM

All replies

  • Hi Paradisp,

    How did you add the custom attributes? And how did you edit through the word UI? I am not very clear about this. Could you show me the reproducible steps about your problem?

     As far as I know, we can add custom attributes according to this article: http://msdn.microsoft.com/en-us/library/ff936167.aspx which contains the detail steps about adding or setting the custom attributes.

    Hope this can give you the hint about your problem

    Best Regards,

     


    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.


    Thursday, June 2, 2011 5:54 AM
  • Thanks Bruce. I'm generating my wordml from an XSLT file that is run against an XML file. Within my XSLT is where I would like to output certain attributes within the standard Wordml elements so that I can easily re-processes the file later. Once created, the Word xml file would then be opened by users in Word where they will make edits to the text through the Word editor and save them back as word xml format. After they have edited those files I would like to run additional XSLT scripts against those files to merge, query, and reformat them as a whole.  So primarily I would need to know how to add these custom attributes to wordml elements through XSLT and make the stick so that I could use those attributes to perform additional processing. I hope that is easier to understand, please let me know if you need any other details. Thanks for your help! 
    Thursday, June 2, 2011 1:28 PM
  • Hi Paradisp,

    We are doing the research about your problem. There might be some delay about the response. Appreciate your patience.

    Best Regards,


    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.


    Friday, June 3, 2011 6:39 AM
  • Hi Bruce,

    Thanks for your help on this. I'll keep an eye out for updates.

    Monday, June 6, 2011 4:41 PM
  • Hi Paradisp,

    Word rewrite the whole document when a document is saved. Unfortunatelly there is no way to retain custom attribute on the node which are generated by Word application.

    Thanks,


    Shiv Khare
    Tuesday, June 7, 2011 4:40 PM
    Moderator
  • Hi Paradisp,

    How's the problem now?  If you need any further assistance, please feel free to let us know.

    Good day!

    Thanks


    Michael Sun [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Monday, June 13, 2011 1:29 AM