XML Encoding issue with namespaces [message #1849373] |
Fri, 14 January 2022 09:10  |
Eclipse User |
|
|
|
Hey, I got the following behaviour. Currently I am not sure whether this is correct or not.
These are the two relevant .ttcn files:
First, the Message which contains the header
module urn_iso_15118_2_2013_MsgDef {
import from XSD all;
import from urn_iso_15118_2_2013_MsgHeader all;
import from urn_iso_15118_2_2013_MsgBody all;
/* attributeFormDefault="unqualified" */
/* Message Structure */
type record V2G_Message
{
MessageHeaderType header,
BodyType body
}
with {
variant "element";
variant (header) "name as capitalized";
variant (body) "name as capitalized";
};
}
with {
encode "XML";
variant "namespace as 'urn:iso:15118:2:2013:MsgDef'";
variant "controlNamespace 'http://www.w3.org/2001/XMLSchema-instance' prefix 'xsi'";
variant "attributeFormQualified";
variant "elementFormQualified";
}
Second, the header type itself
module urn_iso_15118_2_2013_MsgHeader {
import from XSD all;
import from urn_iso_15118_2_2013_MsgDataTypes all;
import from http_www_w3_org_2000_09_xmldsig all;
/* Message Header */
type record MessageHeaderType
{
SessionIDType sessionID,
NotificationType notification optional,
Signature signature_ optional
}
with {
variant (sessionID) "name as capitalized";
variant (notification) "name as capitalized";
variant (signature_) "name as 'Signature'";
variant (signature_) "namespace as 'http://www.w3.org/2000/09/xmldsig#' prefix 'mmlsig'";
};
}
with {
encode "XML";
variant "namespace as 'urn:iso:15118:2:2013:MsgHeader'";
variant "controlNamespace 'http://www.w3.org/2001/XMLSchema-instance' prefix 'xsi'";
variant "attributeFormQualified";
variant "elementFormQualified";
}
Now, this is the resulting XML. Previous versions would attribute the Header tag to the MsgDef namespace, now it has the MsgHeader namespace. The element name ("Header") is only defined in the MsgDef namespace as an element of the record V2G_Message
<tq0003:V2G_Message xmlns:tq0003='urn:iso:15118:2:2013:MsgDef' xmlns:tq0002='urn:iso:15118:2:2013:MsgHeader' xmlns:tq0004='urn:iso:15118:2:2013:MsgDataTypes' xmlns:tq0001='urn:iso:15118:2:2013:MsgBody'><tq0002:Header><tq0004:SessionID>0000000000000000</tq0004:SessionID></tq0002:Header><tq0001:Body><tq0001:SessionSetupReq><tq0004:EVCCID>FEFEFEFEFEFE</tq0004:EVCCID></tq0001:SessionSetupReq></tq0001:Body></tq0003:V2G_Message>
This seems to confuse the EXI generators and parsers I'm working with.
For example EXIficient does not encode this in strict mode and produces an comparatively large bytestream in non-strict mode which in turn is not accepted by proprietary EXI parsers I'm working with.
Edit: Running it against xmllint with the following command
xmllint --schema V2G_CI_MsgDef.xsd test.xml
results in
<?xml version="1.0"?>
<tq0003:V2G_Message xmlns:tq0003="urn:iso:15118:2:2013:MsgDef" xmlns:tq0002="urn:iso:15118:2:2013:MsgHeader" xmlns:tq0004="urn:iso:15118:2:2013:MsgDataTypes" xmlns:tq0001="urn:iso:15118:2:2013:MsgBody"><tq0002:Header><tq0004:SessionID>0000000000000000</tq0004:SessionID></tq0002:Header><tq0001:Body><tq0001:SessionSetupReq><tq0004:EVCCID>FEFEFEFEFEFE</tq0004:EVCCID></tq0001:SessionSetupReq></tq0001:Body></tq0003:V2G_Message>
test.xml:1: element Header: Schemas validity error : Element '{urn:iso:15118:2:2013:MsgHeader}Header': This element is not expected. Expected is ( {urn:iso:15118:2:2013:MsgDef}Header ).
test.xml fails to validate
You can find the scheme here
Looking through recent changes, this looks like it could be related.
I'm not really proficient with XML encoding subtleties, maybe anyone could lighten that up a bit?
Thank you!
Moritz
[Updated on: Fri, 14 January 2022 10:05] by Moderator
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.33516 seconds