Menu

Whitespaces in XML crash rules

2015-03-04
2015-03-10
  • Cristian Lazurean

    We have some rules that use restrictValues. The values from XML files sometimes have whitespaces before and after the actual values. The actual values match with the value list provided to restrictValues but because of the whitespaces the rules are failing.
    Is there a way to ignore the whitespaces?
    Thank you.

    Cristian

     
  • drrwebber

    drrwebber - 2015-03-04

    Cristian, I'm having a little difficult visualizing this - could you post just the sample restrictValues() rule to help? You can post it here - just hit TAB key at start of the line before inserting - that way it retains the code as is.

    Thanks, David

     
  • Cristian Lazurean

    David,

    Here is the error message taken from the console of CAMEd 3.2:

    234503 [main] ERROR uk.org.jcam.camed.ui.wizards.camv.JCamWizard - Error: /itl:NISTBiometricInformationExchangePackage[1]/itl:PackageLatentImageRecord[1]/itl:FingerprintImage[1]/biom:FingerprintImageImpressionCaptureCategoryCode[1]: biom:FingerprintImageImpressionCaptureCategoryCode | Node does not contain an allowed value. =>Node: FingerprintImageImpressionCaptureCategoryCode

    Here is the constraint definition taken from the .cam file:

    <as:constraint action="restrictValues(//itl:FingerprintImage/biom:FingerprintImageImpressionCaptureCategoryCode,'0' |'1' |'2' |'3' |'4' |'5' |'6' |'7' |'8' |'10' |'11' |'12' |'13' |'14' |'15' |'20' |'21' |'22' |'23' |'24' |'25' |'26' |'27' |'28' |'29' |'30' |'31' |'32' |'33' |'34' |'35' |'36' |'37' |'38' |'39')">

    Here is the format of the data taken from the input .xml file:

         <biom:FingerprintImageImpressionCaptureCategoryCode>
            6
         </biom:FingerprintImageImpressionCaptureCategoryCode>
    

    As you can see, between the tags there are some whitespaces (spaces, LineFeeds etc.).
    If we manually remove the whitespaces (like this <biom:FingerprintImageImpressionCaptureCategoryCode>6</biom:FingerprintImageImpressionCaptureCategoryCode>) then the validation is ok.

    Cristian

     
  • drrwebber

    drrwebber - 2015-03-06

    Cristian, strictly speaking according to the XML specification - those spaces are incorrect and it is an error to do that. Notice - persisting that data into a DB would cause similar issues (maybe worse!). BTAIM - here is the work-around using a conditional.

    What this does is check condition="normalize-space( ./This) = ." so that the restrictValues is skipped when that's not true - but then - does an additional check that the length is 1 character.

    David

    <as:constraint condition="normalize-space( ./This) = ." action="restrictValues(//TestRestrictValues/This,'A'|'B'|'C')" />
    <as:constraint action="setLength(//TestRestrictValues/This,1-1)" />
    

    Here

     
    • Cristian Lazurean

      Didn't know about the normalize-space test. I just checked the OASIS CAM specification v1.1 but it does not appear there.
      Where can we found the documentation for all the functions and conditions that CAM allows?

      Cristian

       
      • Cristian Lazurean

        I just figured that normalize-space is coming from XPath.
        Still, we have one issue. The condition as it is in your example do not work. We'll try to figure it out.

         
  • drrwebber

    drrwebber - 2015-03-06

    Cristian, supplemental response.

    Is the sample the typical content your exchanges are using?

    <biom:FingerprintImageImpressionCaptureCategoryCode>
        6
     </biom:FingerprintImageImpressionCaptureCategoryCode>
    

    Yes - we know this is wrong - but do you need the option to handle it anyway?

    We are looking at some simple options to essentially do a normalize-space() on the content in CAMV before running the validation. Your backend will need to ensure it does that same clean-up during any data loading.

    Thanks, David

     

Log in to post a comment.