transforming data 2-ways - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

transforming data 2-ways

Last post 03-09-2005 12:40 AM by Patrick Halstead. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 02-24-2005 09:46 AM

    transforming data 2-ways

    hiya,

    I'm a bit new to InfoPath, and I'm sure what I need can be done somehow, but I can't find much reference to it, except in quite vague terms. Thanks in advance for your patience with my dazzling newbie question


    I've got a project that is collecting XML with information about people living together and what income they receive. There is currently a paper version of the data-collection form, which we are hoping to convert to InfoPath.

    On the form, it displays the details of the head of the household, then asks for a list of other people in the house, and then another section to list all the different incomes of the people in the house (one person can have more than one income, or none).

    So far so good


    However, my problem is that the (non-negotiable) XML schema doesn't look like that. It stores each individual person as equal "person" nodes, under one "persons" node. The only difference between them is a "type" tag, so my first question is:

    can I have a single section of the form which maps directly onto a particular instance of a repeating node, when the specific node is accessible by a XPath query like //person[persontype='head']


    the other main problem is that the income section is not stored together, but as an "income" node beneath each individual "person" node (inside an "incomes" node - each person can have lots of incomes, in theory anyway)

    so, my second question is:

    can i have a set of repeating form elements, which will include drop-down to select the relevant person, which when saved, will be split up into the appropriate sub-nodes as indicated in the person drop-down


    in other words, my data will look like this:

    <?xml version="1.0" encoding="UTF-8"?>
    <people>
    <Person>
    <Name>Mr Tall</Name>
    <DOB>1/1/1960</DOB>
    <Type>Head</Type>
    <Incomes>
    <Income>
    <Amount>25</Amount>
    <Frequency>Weekly</Frequency>
    <IncomeType>Begging</IncomeType>
    </Income>
    <Income>
    <Amount>60</Amount>
    <Frequency>Monthly</Frequency>
    <IncomeType>eBay</IncomeType>
    </Income>
    </Incomes>
    </Person>
    <Person>
    <Name>Mr Small</Name>
    <DOB>1/1/1975</DOB>
    <Type>Foot</Type>
    <Incomes>
    <Income>
    <Amount>500</Amount>
    <Frequency>Monthly</Frequency>
    <IncomeType>Wage</IncomeType>
    </Income>
    </Incomes>
    </Person>
    </people>



    but the for the purposes of the InfoPath form, will need to look something like this:


    <?xml version="1.0" encoding="UTF-8"?>
    <Report>
    <Head>
    <Name>Mr Tall</Name>
    <DOB>1/1/1960</DOB>
    </Head>
    <OtherPeople>
    <Person>
    <Name>Mr Small</Name>
    <DOB>1/1/1975</DOB>
    <Type>Foot</Type>
    <Incomes/>
    </Person>
    </OtherPeople>
    <Incomes>
    <Income>
    <Person>Mr Tall</Person>
    <Amount>25</Amount>
    <Frequency>Weekly</Frequency>
    <IncomeType>Begging</IncomeType>
    </Income>
    <Income>
    <Person>Mr Tall</Person>
    <Amount>60</Amount>
    <Frequency>Monthly</Frequency>
    <IncomeType>eBay</IncomeType>
    </Income>
    <Income>
    <Person>Mr Small</Person>
    <Amount>500</Amount>
    <Frequency>Monthly</Frequency>
    <IncomeType>Wage</IncomeType>
    </Income>
    </Incomes>
    </Report>



    sorry for this incredibly long post, but the main question is:
    can InfoPath do this sort of transformation, to both read and write, internally and seamlessly? Or will I have to do a transformation outside InfoPath first, let it update the data in the second format, then transform it back to the original format


    I saw mention of "views" here:
    http://tinyurl.com/4vftk

    which sounds about right, but can't find anything else to tell me the best way to do it.


    once again, I'm completely new to InfoPath, so would really appreciate someone pointing out the obvious

    cheers

    Toby
  • 02-24-2005 10:11 AM In reply to

    Re: transforming data 2-ways

    just been talking this through with a colleague, and found a slightly different way to explain our basic problem ...

    of the 2 XML examples, the first is the format in which we receive and return the data, the second is the way that most closely matches the format of the form we have to use. Exactly the same data, just stored in different ways

    cheers

    T
  • 03-09-2005 12:40 AM In reply to

    Re: transforming data 2-ways

    Hi T,
    Welcome!
    You can certainly write code to do an xsl apply in the OnSave event. Also, using Import, you could do an xsl apply on load. Not sure if this completely helps you. It's just code. It's doable, but will require some finagling.
    Good luck!
    Patrick Halstead
    Project Manager at Qdabra
Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.