주어진 XML 파일의 유효성을 검사하기 위해 JAXB를 사용하여 XSD를 생성하려고하는데 일부 요소에서 xsi : type 특성에 문제가 있습니다. 나는 네임 스페이스 문제로 여겨지는 것 같지만 정확히 무엇이 잘못되었는지를 알 수 없다. 내가 유효성을 검사 할 때스키마 유효성 검사 및 xsi : type과 관련된 JAXB 문제
내가 나에게 힌트 UIDataConnection
Fehler: cvc-elt.4.2: Cannot resolve 'UIDataConnection' to a type definition for element 'UIData'.
의 CVC-elt.4.2 오류가 그것은 이것은 XML
<?xml version="1.0" encoding="utf-8"?>
<InformationWorkflow xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://foo/bar/baz" workflowguid="22b1941c-efc1-4084-89e6-25dc5eae5161" creator="rbo" creationdate="2014-05-22T14:19:20.4356295+02:00" idnprefix="">
<Name>QA_14-05-22_v1</Name>
<Connections>
<C idn="c:14" start="out:2.2" end="end:3">
<UIData xsi:type="UIDataConnection" row="0" column="0">
<ConnectionAnchor>Unset</ConnectionAnchor>
<ConnectionAnchorOffset>0</ConnectionAnchorOffset>
</UIData>
<ConnectionType>Node</ConnectionType>
</C>
<C idn="c:15" start="out:2.3" end="end:2">
<UIData xsi:type="UIDataConnection" row="0" column="0">
<ConnectionAnchor>Unset</ConnectionAnchor>
<ConnectionAnchorOffset>0</ConnectionAnchorOffset>
</UIData>
<ConnectionType>Node</ConnectionType>
</C>
</Connections>
</InformationWorkflow>
에게하는 네임 스페이스 문제
입니다 여기 내 XSD가 있습니다 :
<xs:schema elementFormDefault="qualified" version="1.0" targetNamespace="http://foo/bar/baz" xmlns:tns="http://foo/bar/baz" xmlns:knsf="http://foo/bar/thing" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<xs:import namespace="http://foo/bar/thing" schemaLocation="schema2.xsd"/>
<xs:import schemaLocation="schema3.xsd"/>
<xs:element name="C" type="tns:connection"/>
<xs:element name="InformationWorkflow" type="tns:typeKnsModel"/>
<xs:complexType name="typeKnsModel">
<xs:complexContent>
<xs:extension base="tns:dataType">
<xs:sequence>
<xs:element name="Name" type="xs:string"/>
<xs:element name="Connections" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element ref="tns:C" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="dataType" abstract="true">
<xs:sequence/>
</xs:complexType>
<xs:complexType name="connection">
<xs:sequence>
<xs:element name="label" type="xs:string" minOccurs="0"/>
<xs:element name="UIData" type="tns:uiDataConnection" minOccurs="0"/>
<xs:element name="ConnectionType" type="xs:string" minOccurs="0"/>
<xs:element name="Description" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="uiDataConnection">
<xs:complexContent>
<xs:extension base="tns:uiData">
<xs:sequence>
<xs:element name="ConnectionAnchor" type="xs:string" minOccurs="0"/>
<xs:element name="ConnectionAnchorOffset" type="xs:double"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="uiData">
<xs:sequence/>
<xs:attribute name="column" type="xs:int" use="required"/>
<xs:attribute name="row" type="xs:int" use="required"/>
</xs:complexType>
</xs:schema>
주석 자바 코드에 53,691,363,210
는 클래스 UIDataConnection는 인 UIData
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "C")
public class Connection
{
@XmlElement(name = "label")
private String label;
@XmlElement(name = "UIData", type = UIDataConnection.class)
private UIDataConnection uiData;
@XmlElement(name = "ConnectionType")
private String connectionType;
@XmlElement(name = "Description")
private String description;
}
...
import javax.xml.bind.annotation.XmlAttribute;
public class UIData
{
@XmlAttribute(name = "column", required = true)
private int column;
@XmlAttribute(name = "row", required = true)
private int row;
}
...
이import javax.xml.bind.annotation.XmlElement;
public class UIDataConnection extends UIData
{
@XmlElement(name = "ConnectionAnchor")
private String connectionAnchor;
@XmlElement(name = "ConnectionAnchorOffset")
private double connectionAnchorOffset;
}
내 package-info.java가
@XmlSchema(
namespace = "http://foo/bar/baz",
elementFormDefault = XmlNsForm.QUALIFIED,
xmlns={
@XmlNs(prefix="knsf", namespaceURI="http://foo/bar/thing"),
@XmlNs(prefix="xsi", namespaceURI = "http://www.w3.org/2001/XMLSchema-instance")
}
)
이 포함되어 확장
XML과 스키마에는 더 많은 UIData 요소가 있지만 여기서는 관련이 없다고 생각합니다.
xsi : type을 올바르게 처리하려면 어떻게해야합니까? package-info에 xsi 네임 스페이스를 정의해야합니까?
감사합니다. 나는 클래스 이름이 충분한 xml 유형의 이름과 같으면 – Madjic