XPath to get multiple attribute values - InfoPath Dev
in

InfoPath Dev

XPath to get multiple attribute values

Last post 02-10-2008 07:31 PM by Jonesie. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 02-10-2008 02:37 PM

    • Jonesie
    • Not Ranked
      Male
    • Joined on 02-10-2008
    • Christchurch, New Zealand
    • Posts 10

    XPath to get multiple attribute values

    Hi

    We have a complex multipart form that is implenented using Form Services. The validation error messages display by Forms Services are, shall we say, less than desirable.  We also need to save forms in a DRAFT state without validations AND I dont want to use any managed code.

    So we have come up with a method of displaying an error message for each required field that will display when the format of the input is blank or doesn't match a pattern.  Fields in the datasource will have a error attribute that gets set by rules.  Conditional display will also make required controls or errors display in red and will set and clear the error attribute.

    I can use the expression '/descendant-or-self::node()/@my:error != "'' ' to disable the submit button which is only on the last view.  I would also like to display ALL the error messages next to the submit button but I can't figure out how to accumulate all the error messages into a single field/control.  I would have thought that /descendant-or-self::node()/@my:error would do this but if I use this as a default value expression then it's setting the value to blank.

    Any ideas?  Remember, this is a web form and I can't (or dont want to) use code.

    Thanks

    Peter G Jones - http://jonesie.net.nz
    Microsoft MVP - ASP.Net
    New Zealand
  • 02-10-2008 03:05 PM In reply to

    Re: XPath to get multiple attribute values

    Hi Peter,

    Glad to see the posts! Have you looked at the eval operator? That's one way to concat multiple nodes into one field that doesn't require code. Check out the following post for an introduction to eval in InfoPath: http://blogs.msdn.com/infopath/archive/2006/04/05/569338.aspx. Not sure this is exactly what you need, but it's just one idea I had. Greg might have other ideas tomorrow. We have some custom tools for Form Services. For example, check out http://www.infopathdev.com/files/folders/dbxldownload/entry26219.aspx for a free tool to allow you to host InfoPath task panes in Form Services. You may also find the UDC editor tool to be useful (per your other post regarding the UDC file).

    Cheers!

    Patrick Halstead
    Project Manager at Qdabra
  • 02-10-2008 04:27 PM In reply to

    • Jonesie
    • Not Ranked
      Male
    • Joined on 02-10-2008
    • Christchurch, New Zealand
    • Posts 10

    Re: XPath to get multiple attribute values

    Hi again

    I tried using eval in the default value:

      xdMath:Eval(/descendant-or-self::node()/@my:error, 'concat(@my:error, ";")')

     and all I got was a single semi-colon in the field.  Also tried using text() in the concat with the same result. 

    Looks promising though...

    Thanks

    Peter G Jones - http://jonesie.net.nz
    Microsoft MVP - ASP.Net
    New Zealand
  • 02-10-2008 06:33 PM In reply to

    Re: XPath to get multiple attribute values

    Hi Peter,

    Did you read the link? You need at least two evals to get the recursion working. One eval won't do it.

    Good luck!

    Patrick Halstead
    Project Manager at Qdabra
  • 02-10-2008 07:31 PM In reply to

    • Jonesie
    • Not Ranked
      Male
    • Joined on 02-10-2008
    • Christchurch, New Zealand
    • Posts 10

    Re: XPath to get multiple attribute values

    Oh, doh!

    eval(eval(descendant-or-self::node()/@error, 'concat(../@my:error, ";")'), "..")

    This is better, but not consistant. If I have a blank field this causes my rules to set an erorr message which is found by this expression.  If I enter alpha chars into a integer field this causes some other validation to fire and the expression returns an empty string - even though the erorr message is still being set by my rules.

    This is hard to explain - I'll try to create a little demo xsn.

    Thanks for your help!

    Cheers

     

     

    Peter G Jones - http://jonesie.net.nz
    Microsoft MVP - ASP.Net
    New Zealand
Page 1 of 1 (5 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.