CA API Management: Converted XML is invalid when transforming JSON
search cancel

CA API Management: Converted XML is invalid when transforming JSON

book

Article ID: 77084

calendar_today

Updated On:

Products

CA API Gateway

Issue/Introduction

The below error is received when using the Apply JSON Transformation assertion

Converted XML is invalid.  Element type "<ElementName>" must be followed by either attribute specifications, ">" or "/>".

Environment

Gateway 10.x and 11.x

Cause

This error is typically caused by invalid characters being transformed as part of the XML Tag Name.

ie:
The below JSON Input would result in an invalid name for an XML Tag.

{"Special@Character":"Value1"}
{"Special/Character":"Value1"}
{"Special#Character":"Value1"}

Per the XML specification (https://www.w3.org/TR/xml/) the First character of the tag name must be within this range:

NameStartChar:
":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]


Additionally, the remaining characters must adhere to 

NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]

Resolution


As a workaround you can use RegEx to remove the special characters before the transformation and then adding them back in post transform.