XML relationship between sibling nodes - InfoPath Dev
in

InfoPath Dev

XML relationship between sibling nodes

Last post 05-09-2007 01:56 AM by rs200. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 05-07-2007 01:40 AM

    • rs200
    • Not Ranked
    • Joined on 02-27-2007
    • Germany
    • Posts 9

    XML relationship between sibling nodes

    Hi all,

    I have following xml structure:
    <root>
        <SectionA>
            <RepeatingGroupA>
                <NameA>A1</NameA>
                <NamespaceA>NS1</NamespaceA>
            </RepeatingGroupA>
            <RepeatingGroupA>
                <NameA>A2</NameA>
                <NamespaceA>NS2</NamespaceA>
            </RepeatingGroupA>
            <RepeatingGroupA>
                <NameA>A3</NameA>
                <NamespaceA>NS3</NamespaceA>
            </RepeatingGroupA>
        </SectionA>
        <SectionB>
            <RepeatingGroupB>
                <NameB>B1</NameB>
                <ContextNamespacB>NS1</ContextNamespacB>
            </RepeatingGroupB>
            <RepeatingGroupB>
                <NameB>B2</NameB>
                <ContextNamespacB></ContextNamespacB>
            </RepeatingGroupB>
            <RepeatingGroupB>
                <NameB>B2</NameB>
                <ContextNamespacB>NS3</ContextNamespacB>
            </RepeatingGroupB>
        </SectionB>
    </root>

    In a table all elements NameA should be shown and the elements NameB where the namespace is the same. If NameA has no matched NameB about the namespace then NameB will be shown as empty field.

    Sample table:
    NameA       | NameB   | Namespace
    =================================
    A1              | B1         | NS1
    A2              | empty    | no Namespace
    A3              | B2         | NS3

    How can I implement this with rules and filters (using XPath) without coding?
  • 05-07-2007 05:48 AM In reply to

    Re: XML relationship between sibling nodes

    In my oppinion it will be hard if not impossible to do this with just using rules. I would suggest using some code to loop through your repeating sections coming from your main or secondary datasource, compare the two namespace fields to each other and then dynamically generate new rows for a third repeating table filling it with either both name values if the namespaces are identical or only with nameA. Just search for "loop through repeating sections" and similar expressions in the forum and you should find what you need.

    If you need more help let me know.

    Listen to Motörhead cos they play Rock'n Roll :)
  • 05-07-2007 06:19 AM In reply to

    Re: XML relationship between sibling nodes

    Actually, this would be pretty easy to do with just expression boxes.
    1. Drop the A structure on the view as a repeating table.
    2. Add 2 blank columns to the table (InfoPath might try to create new nodes in the data source for this, but don't let it)
    3. In the first column add an expression box that has an XPath like /root/SectionB/RepeatingGroupB[ ContextNamespacB = current()/NamespaceA ]/NameB
    4. Second column, add an expression box that has an XPath like /root/SectionB/RepeatingGroupB[ ContextNamespacB = current()/NamespaceA ]/ContextNamespacB
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 05-09-2007 01:56 AM In reply to

    • rs200
    • Not Ranked
    • Joined on 02-27-2007
    • Germany
    • Posts 9

    Re: XML relationship between sibling nodes

    Thanks for your replies.

    I have found a solution. I created an external stylesheet and transform the xml by using the xsl for showing in IE.
     

Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.