Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Options for formXmlStringWithType and fromXmlWithType #6073

Closed
prakanth97 opened this issue Feb 16, 2024 · 3 comments · Fixed by ballerina-platform/module-ballerina-data.xmldata#6

Comments

@prakanth97
Copy link
Contributor

Description:
Allow users to override the default behaviour of XML data library using options such as

  • attributePrefix
  • textFieldName
  • isProjectionAllowed
type Options record {|
    string attributePrefix = "";
    string textFieldName = "#content";
    boolean isProjectionAllowed = true;
|};

Describe your task(s)

Related Issues (optional):

Suggested Labels (optional):

Suggested Assignees (optional):

@hasithaa
Copy link

Alternative name: allowFlexibleDataProjection allowDataProjection

@prakanth97
Copy link
Contributor Author

Alternative name: allowFlexibleDataProjection allowDataProjection

+1 for allowDataProjection

@prakanth97
Copy link
Contributor Author

Options can be passed when converting from XML source to record and record to xml.

Hence introduce two options type as follow

# Represent the options that can be used to modify the behaviour of conversion.
#
# + attributePrefix - prefix added for attribute fields in the record 
# + textFieldName - field name for the text field
public type Options record {|
    string attributePrefix = EMPTY_STRING;
    string textFieldName = "#content";
|};

# Represent the options that can be used to modify the behaviour of conversion in `fromXmlStringWithType` and `fromXmlWithType`.
#
# + allowDataProjection - enable or disable projection
public type SourceOptions record {|
    *Options;
    boolean allowDataProjection = true;
|};

The SourceOptions is used when converting from xml source to record using fromXmlWithType and fromXmlStringWithType function.

The Options is used when converting records to the xml value using toXml function.

Refer: ballerina-platform/module-ballerina-data.xmldata#6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants