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

Setting nilAttribute configuration to xsi:nil="true" results in sequence order of element not be preserved #152

Closed
frenchmb opened this issue Jun 8, 2023 · 1 comment
Labels
indev The issue is fixed/implemented in the dev branch

Comments

@frenchmb
Copy link

frenchmb commented Jun 8, 2023

We have the following configuration for the XML parser:

nilAttribute = qname(Namespaces.XmlSchemaInstance, "nil", Prefixes.XmlSchemaInstance) to "true"

When we serialize a class the order of the element is not preserved when an element is null:

<Parameters> <IgnoreLimitWarningsArray xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/> <ExecutionInstructionsArray xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/> <ExecutionInstructionsDictionaryArray xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/> <ExecutionInstructionsRestatedArray xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/> <ClientSequenceNumberArray xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/> <CustomColumnsArray xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/> <CustomColumnsRestatedArray xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/> <TradingPassword xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/> <OrderNumberArray> <OrderNumber>138084514</OrderNumber> </OrderNumberArray> </Parameters>

All the nil elements are placed at the top which is not the correct definition of sequence order:

`@Serializable
@XmlSerialName(value = "Parameters")
class OrderDelete (
@xmlelement
@XmlSerialName("OrderNumberArray")
@XmlChildrenName("OrderNumber", namespace = "http://webservices.iress.com.au/v4/")
val orderNumberArray: List,

@XmlElement
@XmlSerialName("IgnoreLimitWarningsArray")
@XmlChildrenName("IgnoreLimitWarnings", namespace = "http://webservices.iress.com.au/v4/")
val ignoreLimitWarningsArray: List<Boolean>? = null,

@XmlElement
@XmlSerialName("ExecutionInstructionsArray")
@XmlChildrenName("ExecutionInstructions", namespace = "http://webservices.iress.com.au/v4/")
val executionInstructionsArray: List<String>? = null,

@XmlElement
@XmlSerialName("ExecutionInstructionsDictionaryArray")
val executionInstructionsDictionary: List<IressDictionary>? = null,

@XmlElement
@XmlSerialName("ExecutionInstructionsRestatedArray")
@XmlChildrenName("ExecutionInstructionsRestated", namespace = "http://webservices.iress.com.au/v4/")
val executionInstructionsRestatedArray: List<Boolean>? = null,

@XmlElement
@XmlSerialName("ClientSequenceNumberArray")
@XmlChildrenName("ClientSequenceNumber", namespace = "http://webservices.iress.com.au/v4/")
val clientSequenceNumberArray: List<Long>? = null,

@XmlElement
@XmlSerialName("CustomColumnsArray")
@XmlChildrenName("CustomColumns", namespace = "http://webservices.iress.com.au/v4/")
val customColumnsArray: List<String>? = null,

@XmlElement
@XmlSerialName("CustomColumnsRestatedArray")
@XmlChildrenName("CustomColumnsRestated", namespace = "http://webservices.iress.com.au/v4/")
val customColumnsRestatedArray: List<Boolean>? = null,

@XmlElement
@XmlSerialName("TradingPassword")
val tradingPassword: String? = null,

)`

Unfortunately the SOAP service we are integrating to requires the order to be preserved. Is the away to fix this?

@pdvrieze pdvrieze added the indev The issue is fixed/implemented in the dev branch label Jun 9, 2023
@pdvrieze
Copy link
Owner

pdvrieze commented Jun 9, 2023

This is actually the result of a bug that could also cause crashes if tag children exist before attributes. This should now be fixed in dev (and the automatically generated snapshot release).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
indev The issue is fixed/implemented in the dev branch
Projects
None yet
Development

No branches or pull requests

2 participants