cancel
Showing results for 
Search instead for 
Did you mean: 

Handling empty values during xml validation

Former Member
0 Kudos

Hello experts,

I have a file to file scenario in PI 7.1. I am using xml validation to validate the incoming source file. There are various types of fields in the incoming file including int, decimal and string. They can have a certain enumeration of values but can also have a blank value.

For example field 'Num' of type int can have values 1,2,3 or a blank value.

But I am not able to define a blank value for the field in the enumeration during definition. Therefore a blank value in the input file fails during the validation stage.

Is there any workaround for this?

Thanks!

RR

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

I think that if an integer field may contains blank values is not a correctly populated integer field.

Fabio

Former Member
0 Kudos

Indeed Fabio.

But I am fine with reading it as string as well and allotting the enumeration values. There still doesnt seem to be any way of mentioning blank value in the enumeration.

Thanks,

RR

baskar_gopalakrishnan2
Active Contributor
0 Kudos

This is a basic problem. When you define a field as integer you cannot declare blank space which represents String type.

So for your case make the value 'zero' instead of blank, if you want do declare the field as integer and as below...

<xs:element name="Num">
  <xs:simpleType>
    <xs:restriction base="xs:integer">
      <xs:pattern value="[0-3]"/>
    </xs:restriction>
  </xs:simpleType>
</xs:element>

Also refer this page for further reference.

http://www.w3schools.com/schema/schema_facets.asp

Former Member
0 Kudos

Hello Bhaskar,

My understanding is that the above declaration will only include the value 0 in the enumeration but will not cater to the requirement of including blank value in the enumeration. I have tried changing the type to string and included hexa value 0x00(null) and 0x20(space) in the enumeration. It is still not accepting the empty values in the input file.

Thanks,

RR

baskar_gopalakrishnan2
Active Contributor
0 Kudos

IMO, You can specify empty values only thru string not using integer. Try this...

<xs:element name="Num">

<xs:simpleType>

<xs:minLength value="0" />

<xs:restriction base="xs:string">

<xs:pattern value="[1-3]"/>

</xs:restriction>

</xs:simpleType>

</xs:element>

Former Member
0 Kudos

Yes. Sure empty values can be read when the field is defined as a string. But the problem is mentioning it in enumeration.

For eg I can have values 1,2,3 or a blank value for a field F1.

How do I indicate the blank value in the enumeration?

Thanks,

RR

Former Member
0 Kudos

Hi,

take a look at this:

Fabio

baskar_gopalakrishnan2
Active Contributor
0 Kudos

refer this [link|http://www.jguru.com/faq/view.jsp?EID=1275160]...

Former Member
0 Kudos

@Fabio,

Regular expression can be ideal when there is a pattern to the values coming in. Since in this case, it is a set of random values that the field can have, i will have to write a regular expression with many 'OR'. Can be done but a little roundabout. I ll probably go for that if nothing else works out.

@Bhaskar

The link indicates adding '' as a enumeration value. I tried this as well but did not exactly work out. I ll probably edit the xsd manually and try to add this value as an enumeration.

Thanks guys!

baskar_gopalakrishnan2
Active Contributor
0 Kudos

In addition to that link, also try giving after restriction. Please see that helps...

<xs:minLength value="0" />

Former Member
0 Kudos

Hello Bhaskar,

Minimum length is already zero. The error thrown is not because of the length but the value.

Thanks!

RR