pub.flatFile:convertToString

  • We have flatfile schema created out of flat file Dictionary. One of the fields in the record is mandatory.
  • I use pub.flatFile:convertToString service to convert the document to flat file (CSV) string
  • In the pipeline I have set the pub.flatFile:convertToString/signalerror to true to signal errors while generating the flat file


The problem is when pub.flatFile:convertToString doesn’t throw any error even though the mandatory field is not present. pub.flatFile:convertToString converts the flat file string with empty space for the mandatory fields

Document
Field1- Non Mandatory
Field2- Mandatory
Field3 –Non Mandatory.

Converts to below flat file with out throwing error.
Field1, ,Field3


can you please help me in this regard.

thanks
Srinivas

Are you sure the field is not present? Is it present but just empty?

By Default webMethods will not display in the document if the Field is empty.

So the field is not present in the document.

There is a difference between null and empty.

There is a difference between a document and a field.

The results pane of Developer does not conditionally display a document based upon whether or not a field within exists or is empty. If the document is in the pipeline (not null), Developer will display it. If a field within a document is present but has a null value, it will be displayed (with the literal null displayed in red as the value). If a field within a document is present and has a value (even if it is empty) it will be displayed.

But anyway, I earlier missed what you were doing. convertToString doesn’t perform validation. You can either validate the IS document using the validate service before calling convertToValues (you’ll need an IS schema or IS doc type), or you can use convertToString followed by a convertToValues with validate set to true.

Hi reamon,

Can you please tell in detail to how to validate a flatfile…if it doesn’t contain the required fields…but null values.

I do not want to generate a flatfile…if the mandatory fields are null or empty.

Please help.

In the Flat-File Schema in the “Flat File Structure” properties section click on the particular mandatory fields and set up a custom Format Service using the specification available on the WmFlatFile package

pub.flatFile:FormatService (pass inputs to check the value minLength/MaxLength),so that convertToString will validate it before generating flatfile string.

Pls review the FlatFile user guide for more info about the FormatService

HTH,
RMg

Hi ,

Thanks for your reply. I am not able to perform the Format service. Can you please tell in detail.

Also, Is there any other way to validate the flatfile string…whether all required fields are present or not. Like creating a xml Schema and then validating it.? Is it possible.

Also, Can you please tell how to create an XSD or DTD for the flatfile schema structure…so that i can create Schema and then use…schema.validate service? can you please tell any softwares which are available to create XSD or DTD.

Please help…

Regards,
David.

Review pub.schema:validate. You can use it to verify an IS document before even attempting to convert it to a flat file. Define an IS document type, setting the various properties of each field as appropriate, and use that to validate the IS doc.

Hi reamon,

I am converting a IDOC to flatfile.where I created a flatfile schema…and in the convert to string…I am giving the schema name where all the properties for the fields are set. But I think converttostring doesn’t validate…it allows null values.

So, In order to validate it using pub.schema.validate…I think I need to create a schema of the Document type which i created from the flatfile schema. Am I right? My question is how can i create the schema of the document type…please help.

Thanks for your patience.

Regards,
David.

convertToString does indeed validate if the inputs to that service indicate it should do so. The FF schema needs to indicate that a field is required. Also, there is a system-wide property that controls whether or not required fields are enforced or not, though I do not recall the name. The property starts with watt.validate or something similar. Review the server.cnf file directly or via the Extended settings in Administrator.

“I think I need to create a schema of the Document type which i created from the flatfile schema.”

That’s one way.

Another is to set the properties of the document type itself to the settings you need. E.g. required field, etc.

Then pass the name of the document type, rather than a schema, to validate.

Hi reamon,

Thanks a lot for your response. I can finally avoid accepting null values into the flatfile by validating it with the document type.

But still I would like to know the other way…where we give the schema as the “conforms to” in the validate.schema. I would like to know how to create an XSD or DTD of the document type inorder to create a schema.

Can you please help.

Thanks in advance,
David.

An XSD can be created manually using any XML schema editor.

The service pub.schema:createXSD can create an XSD from an IS document type. This still requires that you define all the constraints within the IS document type, so the benefit of having an XSD to use to create a corresponding IS schema seems minimal, depending on needs.

Does convertToString perform validation or not? I found it doesn’t.

==============================================
The previous message is
But anyway, I earlier missed what you were doing. convertToString doesn’t perform validation. You can either validate the IS document using the validate service before calling convertToValues (you’ll need an IS schema or IS doc type), or you can use convertToString followed by a convertToValues with validate set to true.