XSD был доставлен моим клиентом, поэтому я не могу его изменить.Вот его начало:
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:ocs="http://www.odette.org/OFTPCommunicationSetup"
targetNamespace="http://www.odette.org/OFTPCommunicationSetup"
elementFormDefault="qualified">
<element name="OftpCommunicationSetup" type="ocs:OftpCommunicationSetupType"/>
<complexType name="OftpCommunicationSetupType">
<sequence>
<element name="StationInformation" type="ocs:StationInfoType" minOccurs="1" maxOccurs="1"/>
<element name="InboundCommunicationSettings" type="ocs:InboundCommunicationSettingsType" minOccurs="1"
maxOccurs="1"/>
<element name="OutboundCommunicationSettings" type="ocs:OutboundCommunicationSettingsType" minOccurs="1"
maxOccurs="1"/>
<element name="CipherSetting" type="ocs:CipherSettingType" minOccurs="0" maxOccurs="1"/>
<element name="SessionSettings" type="ocs:SessionSettingsType" minOccurs="1" maxOccurs="1"/>
<element name="OutboundFileSettings" type="ocs:FileSettingsType" minOccurs="1" maxOccurs="1">
</element>
<element name="InboundFileSettings" type="ocs:FileSettingsType" minOccurs="1" maxOccurs="1">
</element>
<element name="SubStations" type="ocs:SubStationsType" minOccurs="0" maxOccurs="1"/>
<element name="Certificates" type="ocs:CertificatesType" minOccurs="0" maxOccurs="1"/>
</sequence>
<attribute name="version" type="string" use="required">
</attribute>
<attribute name="docid" type="ID" use="required">
</attribute>
...
Генерируемый класс ´OFTPCommunicationSetup´ аннотируется так:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "OftpCommunicationSetupType", propOrder = {
"stationInformation",
"inboundCommunicationSettings",
"outboundCommunicationSettings",
"cipherSetting",
"sessionSettings",
"outboundFileSettings",
"inboundFileSettings",
"subStations",
"certificates"
})
public class OftpCommunicationSetupType {
@XmlElement(name = "StationInformation", required = true)
protected StationInfoType stationInformation;
@XmlElement(name = "InboundCommunicationSettings", required = true)
protected InboundCommunicationSettingsType inboundCommunicationSettings;
@XmlElement(name = "OutboundCommunicationSettings", required = true)
protected OutboundCommunicationSettingsType outboundCommunicationSettings;
@XmlElement(name = "CipherSetting")
protected CipherSettingType cipherSetting;
@XmlElement(name = "SessionSettings", required = true)
protected SessionSettingsType sessionSettings;
@XmlElement(name = "OutboundFileSettings", required = true)
protected FileSettingsType outboundFileSettings;
@XmlElement(name = "InboundFileSettings", required = true)
protected FileSettingsType inboundFileSettings;
@XmlElement(name = "SubStations")
protected SubStationsType subStations;
@XmlElement(name = "Certificates")
protected CertificatesType certificates;
@XmlAttribute(name = "version", required = true)
protected String version;
@XmlAttribute(name = "docid", required = true)
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
@XmlID
@XmlSchemaType(name = "ID")
protected String docid;
@XmlAttribute(name = "docdate", required = true)
@XmlSchemaType(name = "dateTime")
protected XMLGregorianCalendar docdate;
@XmlAttribute(name = "validfrom", required = true)
@XmlSchemaType(name = "dateTime")
protected XMLGregorianCalendar validfrom;
...
Маршаллированный XML из экземпляра объекта начинается так:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<OftpCommunicationSetup xmlns="http://www.odette.org/OFTPCommunicationSetup" docid="4cc78e17561f4e0a8062462e72b9939d" docdate="2019-06-13T15:29:08.099+02:00">
<StationInformation>
<DUNS>987654321</DUNS>
<Name>Wiley E. Coyote Corporation</Name>
<CompanyInfo>
<Name>Wiley E. Coyote Corporation</Name>
</CompanyInfo>
<OdetteIDCode>O017700000000COYOTE000001</OdetteIDCode>
</StationInformation>
...
Проверка этого XML на XSD теперь утверждает:
The XML-file is not valid with the according XSD-Schema cvc-datatype-valid.1.2.1: '4cc78e17561f4e0a8062462e72b9939d' is not a valid value for 'NCName'.
Я, честно говоря, не понимаю, почему этот UUID для атрибута docid не должен быть действительным NCName.NCName в основном требует, чтобы в ID не было ":", верно?