XML Encoding issue with namespaces [message #1849373] |
Fri, 14 January 2022 14:10 |
Moritz Klass Messages: 22 Registered: August 2020 |
Junior Member |
|
|
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 15:05] Report message to a moderator
|
|
|
|
|
|
|
|
Re: XML Encoding issue with namespaces [message #1852765 is a reply to message #1852569] |
Fri, 03 June 2022 09:35 |
Moritz Klass Messages: 22 Registered: August 2020 |
Junior Member |
|
|
Hi Adam, thanks for the response!
From what I gather from the xmllint output and comparisons of other schemes and their usages, this seems to be indeed a bug.
The Header element in my case is simply not present in the {urn:iso:15118:2:2013:MsgHeader} namespace, but only in the {urn:iso:15118:2:2013:MsgDef} one.
I will try to find some relevant arguments online, if I get the time.
Edit:
This is the MsgDef scheme:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="urn:iso:15118:2:2013:MsgDef" xmlns:v2gci_h="urn:iso:15118:2:2013:MsgHeader"
xmlns:v2gci_b="urn:iso:15118:2:2013:MsgBody" targetNamespace="urn:iso:15118:2:2013:MsgDef"
elementFormDefault="qualified" attributeFormDefault="qualified" version="15118 2.0">
<!-- attributeFormDefault="unqualified" -->
<xs:import namespace="urn:iso:15118:2:2013:MsgHeader" schemaLocation="V2G_CI_MsgHeader.xsd"/>
<xs:import namespace="urn:iso:15118:2:2013:MsgBody" schemaLocation="V2G_CI_MsgBody.xsd"/>
<!-- Message Structure -->
<xs:element name="V2G_Message">
<xs:complexType>
<xs:sequence>
<xs:element name="Header" type="v2gci_h:MessageHeaderType"/>
<xs:element name="Body" type="v2gci_b:BodyType"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
The "Header" element which is generated by titan can only be found here!
[Updated on: Fri, 03 June 2022 09:40] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05612 seconds