Preceding (and following) sibling with attributes - InfoPath Dev
in

InfoPath Dev

Preceding (and following) sibling with attributes

Last post 10-11-2011 09:29 AM by Jimmy. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 10-11-2011 05:16 AM

    Preceding (and following) sibling with attributes

    Hi

    I am using infopath 2007

    I have a data paths which look like this…

    /dfs:myFields/dfs:dataFields/d:ApplicationAliases/@Alias

    /dfs:myFields/dfs:dataFields/d:ApplicationAliases/@ApplicationID

    Where ApplicationAliases is repeating.

    I need to ensure that combinations of @ApplicationID and @Alias are unique.  Applicationid is a dropdown, Alias is a text field.  I need to translate Alias to stop xyz and XYZ being entered.

    So my plan was to get the preceding sibling working on @Alias – then change it to be @Alias[../@ApplictionID=current()../@Applicationid] (I don’t know if that will work - correction would be appreciated !).

    So in trying to get the preceding/following sibling to work I started with the following, which Jimmy helped me get working in another form of slightly different structure.

    translate(., "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz") = xdMath:Eval(preceding-sibling::my:Aliases | following-sibling::my:Aliases, "translate(., 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')")

    (many thanks to Jimmy for his help in this one.)

    Initially I tried changing my:Aliases to @Alias – but that does not work, I have found the post http://www.infopathdev.com/forums/p/6891/25126.aspx#25126 which I think may be a similar problem to mine – my understanding of this is that I need to go UP the data tree and then back down again – so I have tried ../@Alias still to no avail.

    Could someone point me in the right direction please ?

    Thank you

    Catharine

     

    Filed under:
  • 10-11-2011 05:55 AM In reply to

    Re: Preceding (and following) sibling with attributes

    Well, the simple answer to how to use preceding and following sibling with this structure would be to use something like this:

    ../preceding-sibling::d:ApplicationAliases/@Alias

    But since you're checking for unique combinations, you might have a complicated situation on your hands. Are you saying that

    John    App1
    John    App2
    Jill       App1
    Jill       App2

     would be ok, but

    John    App2
    John    App2
    Jill       App1
    Jill       App2

    would be invalid because there are two John - App2 rows?

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 10-11-2011 06:12 AM In reply to

    Re: Preceding (and following) sibling with attributes

    Yes that is exactly the case.

    Every app  and every alias may appear serveral times.... but it is the combination which has to be unique

    Catharine

  • 10-11-2011 06:26 AM In reply to

    Re: Preceding (and following) sibling with attributes

    How's this:

    translate(concat(. , '[|]', ../@ApplicationID), "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz") = xdMath:Eval(../preceding-sibling::d:ApplicationAliases | ../following-sibling::d:ApplicationAliases, "translate(concat(@Alias, '[|]', @ApplicationID), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')")

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 10-11-2011 06:44 AM In reply to

    Re: Preceding (and following) sibling with attributes

    I have put this in my form and it works - you are a super hero...

    I am now trying to 'decode' it for the future...

    translate(concat(. , '[|]', ../@ApplicationID), "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz")  - I think you are concatenating the two items together first, then translating the concatenated result.

     xdMath:Eval(../preceding-sibling::d:ApplicationAliases | ../following-sibling::d:ApplicationAliases, "translate(concat(@Alias, '[|]', @ApplicationID), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')")

    - so in this bit you are going to the parent and getting the preceding following siblings - then concatenating the Alias and ApplicationID 

     Brilliant !

    Thank you very much

  • 10-11-2011 09:29 AM In reply to

    Re: Preceding (and following) sibling with attributes

    Excellent!  Glad to help, and it looks like you're understanding the logic just fine. 

    Just so you know, the '[|]' there is an arbitrary piece of text to separate the Alias and ApplicationID, so that there's no risk of false positives when you concatenate them together.  I used '[|]' because I figured that character sequence was unlikely to appear in either of those fields.

     Happy trails!

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
Page 1 of 1 (6 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.