none
CustomXml - Content control XPath binding - Multiple XmlNodes / Forumla auto-refresh RRS feed

  • Question

  • Hi,
    I'm trying to create list of values, and possibly to calculate sum of that values.

    Let's assume that this is my CustomXml part:

    <User>
      <Payment>123</Payment>
      <Payment>456</Payment>
      <Payment>789</Payment>
    </User>
    XPath \\User\\Payment would return list of nodes. In some cases, I will know, beforehand, the exact number of nodes, so I can create N Content Controls (3 in this case), and do manual binding, as \\User\\Payment[0], \\User\\Payment[1], \\User\\Payment[2]...

    And If I put new Content Control and put in it Formula =A1+B1+C1, or if I put CCs in table, then I can put SUM(ABOVE) or SUM(LEFT) or something similar...
     
    Main problem is that often I will not know number of XmlNodes that XPath expression will return. So is there any workaround for creating CCs dinamicaly and mapping them with corect XPath expression.

    Another issue that came up is auto-refresh of forumula. When I create formula, lets say SUM(ABOVE). If there are some values in conten controls, and then I create formula, it calculates that value.
    If I first put formula, and then values, value is not calculated, until I press F9.

    That is major problem for me. My goal is to create word files that are mapped, and then in runtime I replace CustomXml part, and print document. So if I don't do manual refresh, it prints old values. If I have to open word, hit f9, and then print document, there's no that much gain from automation.
    Monday, April 27, 2009 3:14 PM

Answers

  • Hi milaneric,

    Have you figured out the workaround? I came across this article talking about inserting arbitrary number of data items in the table in the content control. Can you use that way to implememt your scenario? and could you please explain more details of your user scenario?
    Is this application running on server?
    Do you use database at the backend?
    Are you generaing the reports from template?
    Do you need to convert the generated document to other file formats, such as PDF? If yes, why?
    How will the result documents be assumed typically, send, print, view online,...?
    Thanks for providing the infomation, thanks:)
    • Marked as answer by Milan Erić Wednesday, June 10, 2009 9:09 AM
    Tuesday, June 9, 2009 8:54 AM

All replies

  • i am not very clear on the 1st issue. what does "dynamic" mean? why you cannot get the number of nodes when you do the binding thing?
    for the 2nd issue, so far as i know, there's no dirty value in SDK to indicate client that it needs to refresh the value.
    Wednesday, April 29, 2009 9:07 AM
  • I have document that has table in it. Is there a way for me to create Content Control in one cell, and put XPath binding \\User\Payment in it, and then word "recognizes" that it's not single value, but list, and than generates N content controls with values (where N is number of nodes). Something like Reporting Services have. If you put value (binding) into the cell, it generates new rows in which to put data.

    I don't want to use new document for every user. Because of that I don't know the number of payments. I want to bind CC to custom xml, and than just replace it for every user, so it's impossible for me to do binding for every user, when thay can have, 0, 1, or more payments.

    For 2nd issue.. I am aware of that, because if "dirty" value existed auto-refresh would work. My question is this, is it possible to call refresh from code, since I have to access word document anyway when I add/replace CustomXml part
    Wednesday, April 29, 2009 9:21 AM
  • I understand your scenario, it seems you needs high-level intelligence. there's also no refresh mechanism in SDK. 

    Thursday, April 30, 2009 3:18 AM
  • Hi milaneric,

    Have you figured out the workaround? I came across this article talking about inserting arbitrary number of data items in the table in the content control. Can you use that way to implememt your scenario? and could you please explain more details of your user scenario?
    Is this application running on server?
    Do you use database at the backend?
    Are you generaing the reports from template?
    Do you need to convert the generated document to other file formats, such as PDF? If yes, why?
    How will the result documents be assumed typically, send, print, view online,...?
    Thanks for providing the infomation, thanks:)
    • Marked as answer by Milan Erić Wednesday, June 10, 2009 9:09 AM
    Tuesday, June 9, 2009 8:54 AM
  • Thanks goodal!

    It wasn't exactly what I was looking for, but it gave me an idea that I can use.

    Application will be running on server. There docx will be modified, data (custom xml) inserted, and than file will be saved as pdf, and than sent back.

    Documents will primary be used for printing, so no editing should be allowed. So I chose pdf over locking docx file
    Wednesday, June 10, 2009 9:19 AM