-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug when modifying the last type declaration in a schema.
In the original code, there were two calls to root.Children = append(root.Children, t) Because the `Children` field is a `[]xmltree.Element`, rather than an `[]*xmltree.Element`, if the call to `append()` causes a reallocation, of the underlying array, then the `el` pointer used within the same loop will no longer point to the current value, and updates to it will be lost, as the added test demonstrated. A better change would be to factor out the rearrangement of XMl such as <element name="foo"> <complexType name="foo"> ... </complexType> </element> to <element name="foo" type="foo"/> <complexType name="foo"> ... </complexType> in a separate pass, rather than doing it in two places (the `copyEltNamesToAnonymousTypes` and `nameAnonymousTypes` functions).
- Loading branch information
Showing
3 changed files
with
48 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"_self": { | ||
"Elements": [ | ||
{ | ||
"Name": {"Space": "tns", "Local": "TradePrice"}, | ||
"Type": { | ||
"Base": 0, | ||
"Name": {"Local": "TradePrice"}, | ||
"Elements": [{"Name": {"Local": "price"}, "Type": 21}] | ||
} | ||
}, | ||
{ | ||
"Name": {"Space": "tns", "Local": "TradePriceRequest"}, | ||
"Type": { | ||
"Base": 0, | ||
"Name": {"Local": "TradePriceRequest"}, | ||
"Elements": [{"Name": {"Local": "tickerSymbol"}, "Type": 38}] | ||
} | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<!-- Where possible (if the type name has not been used already), anonymous types | ||
declared inside an element or attribute should have the same name as their container. --> | ||
|
||
<element name="TradePrice"> | ||
<complexType> | ||
<all> | ||
<element name="price" type="float"/> | ||
</all> | ||
</complexType> | ||
</element> | ||
<element name="TradePriceRequest"> | ||
<complexType> | ||
<all> | ||
<element name="tickerSymbol" type="string"/> | ||
</all> | ||
</complexType> | ||
</element> |