2014-12-29 1 views
-5

xml xsd에서 처음으로 작업하기.
다음과 같이 xsd 및 xml 데이터가 있습니다. 유효성을 검사하려고하면 오류가 발생합니다.
코드 및 오류.xml-xsd 유효성 검사 디버깅

제게 잘못 가고있는 것을 찾는 것을 도와주세요.

XSD :

<?xml version="1.0" encoding="UTF-8"?> 
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:t="http://www.m5net.com/mantle/configuration/connectors" targetNamespace="http://www.m5net.com/mantle/configuration/connectors" elementFormDefault="qualified"> 
    <xsd:element name="Bullhorn" type="t:Bullhorn" nillable="true" /> 
    <xsd:element name="Configuration" type="t:Configuration" nillable="true" /> 
    <xsd:element name="Lync" type="t:Lync" nillable="true" /> 
    <xsd:element name="SalesForce" type="t:SalesForce" nillable="true" /> 
    <xsd:element name="ShoreTelCosmoMobility" type="t:ShoreTelCosmoMobility" nillable="true" /> 
    <xsd:element name="ShoreTelCosmoScribe" type="t:ShoreTelCosmoScribe" nillable="true" /> 
    <xsd:element name="ShoreTelFax" type="t:ShoreTelFax" nillable="true" /> 
    <xsd:element name="ShoreTelMobility" type="t:ShoreTelMobility" nillable="true" /> 
    <xsd:element name="ShoreTelScribe" type="t:ShoreTelScribe" nillable="true" /> 
    <xsd:element name="ShoretelCosmoConference" type="t:ShoretelCosmoConference" nillable="true" /> 
    <xsd:element name="ShoretelCosmoMobility" type="t:ShoretelCosmoMobility" nillable="true" /> 
    <xsd:complexType name="Bullhorn"> 
     <xsd:complexContent> 
     <xsd:extension base="t:Configuration"> 
      <xsd:sequence> 
       <xsd:element name="AccountId" type="xsd:int" minOccurs="0" /> 
       <xsd:element name="CorporationID" type="xsd:int" minOccurs="0" /> 
       <xsd:element name="Password" type="xsd:string" minOccurs="0" nillable="true" /> 
       <xsd:element name="PrivateLabelID" type="xsd:int" minOccurs="0" /> 
       <xsd:element name="UserName" type="xsd:string" minOccurs="0" nillable="true" /> 
      </xsd:sequence> 
     </xsd:extension> 
     </xsd:complexContent> 
    </xsd:complexType> 
    <xsd:complexType name="Configuration"> 
     <xsd:complexContent> 
     <xsd:restriction base="xsd:anyType"> 
      <xsd:sequence /> 
     </xsd:restriction> 
     </xsd:complexContent> 
    </xsd:complexType> 
    <xsd:complexType name="Lync"> 
     <xsd:complexContent> 
     <xsd:extension base="t:Configuration"> 
      <xsd:sequence> 
       <xsd:element name="TrustedAppComputerFQDN" type="xsd:string" /> 
       <xsd:element name="TrustedAppPort" type="xsd:int" /> 
       <xsd:element name="TrustedAppComputerGRUU" type="xsd:string" /> 
       <xsd:element name="CertificateFriendlyName" type="xsd:string" /> 
       <xsd:element name="TrustedAppEndpointOwnerURI" type="xsd:string" /> 
       <xsd:element name="RegistrarFQDN" type="xsd:string" /> 
       <xsd:element name="RegistrarPort" type="xsd:int" /> 
       <xsd:element name="AccountId" type="xsd:int" /> 
      </xsd:sequence> 
     </xsd:extension> 
     </xsd:complexContent> 
    </xsd:complexType> 
    <xsd:complexType name="SalesForce"> 
     <xsd:complexContent> 
     <xsd:extension base="t:Configuration"> 
      <xsd:sequence> 
       <xsd:element name="IsSandbox" type="xsd:boolean" minOccurs="0" /> 
       <xsd:element name="Password" type="xsd:string" minOccurs="0" nillable="true" /> 
       <xsd:element name="Token" type="xsd:string" minOccurs="0" nillable="true" /> 
       <xsd:element name="UserName" type="xsd:string" minOccurs="0" nillable="true" /> 
      </xsd:sequence> 
     </xsd:extension> 
     </xsd:complexContent> 
    </xsd:complexType> 
    <xsd:complexType name="ShoreTelCosmoMobility"> 
     <xsd:complexContent> 
     <xsd:extension base="t:Configuration"> 
      <xsd:sequence> 
       <xsd:element name="AccountId" type="xsd:int" minOccurs="0" nillable="true" /> 
       <xsd:element name="GroupId" type="xsd:string" minOccurs="0" nillable="true" /> 
      </xsd:sequence> 
     </xsd:extension> 
     </xsd:complexContent> 
    </xsd:complexType> 
    <xsd:complexType name="ShoreTelCosmoScribe"> 
     <xsd:complexContent> 
     <xsd:extension base="t:Configuration"> 
      <xsd:sequence> 
       <xsd:element name="AccountId" type="xsd:int" minOccurs="0" nillable="true" /> 
       <xsd:element name="GroupId" type="xsd:string" minOccurs="0" nillable="true" /> 
      </xsd:sequence> 
     </xsd:extension> 
     </xsd:complexContent> 
    </xsd:complexType> 
    <xsd:complexType name="ShoreTelFax"> 
     <xsd:complexContent> 
     <xsd:extension base="t:Configuration"> 
      <xsd:sequence> 
       <xsd:element name="AccountId" type="xsd:int" minOccurs="0" /> 
       <xsd:element name="ConfirmReceipt" type="xsd:int" minOccurs="0" /> 
       <xsd:element name="ConfirmSent" type="xsd:int" minOccurs="0" /> 
       <xsd:element name="IncludeCover" type="xsd:int" minOccurs="0" /> 
      </xsd:sequence> 
     </xsd:extension> 
     </xsd:complexContent> 
    </xsd:complexType> 
    <xsd:complexType name="ShoreTelMobility"> 
     <xsd:complexContent> 
     <xsd:extension base="t:Configuration"> 
      <xsd:sequence> 
       <xsd:element name="AccountId" type="xsd:int" minOccurs="0" /> 
       <xsd:element name="GroupID" type="xsd:string" minOccurs="0" nillable="true" /> 
      </xsd:sequence> 
     </xsd:extension> 
     </xsd:complexContent> 
    </xsd:complexType> 
    <xsd:complexType name="ShoreTelScribe"> 
     <xsd:complexContent> 
     <xsd:extension base="t:Configuration"> 
      <xsd:sequence> 
       <xsd:element name="AccountId" type="xsd:int" minOccurs="0" /> 
       <xsd:element name="PlanId" type="xsd:int" minOccurs="0" /> 
       <xsd:element name="SendImmediate" type="xsd:int" minOccurs="0" /> 
       <xsd:element name="SubplanId" type="xsd:int" minOccurs="0" /> 
      </xsd:sequence> 
     </xsd:extension> 
     </xsd:complexContent> 
    </xsd:complexType> 
    <xsd:complexType name="ShoretelCosmoConference"> 
     <xsd:complexContent> 
     <xsd:extension base="t:Configuration"> 
      <xsd:sequence> 
       <xsd:element name="AccountId" type="xsd:int" minOccurs="0" nillable="true" /> 
       <xsd:element name="StartConference" type="xsd:string" minOccurs="0" nillable="true" /> 
       <xsd:element name="EndConference" type="xsd:string" minOccurs="0" nillable="true" /> 
       <xsd:element name="WebLoginMode" type="xsd:string" minOccurs="0" nillable="true" /> 
       <xsd:element name="Password" type="xsd:string" minOccurs="0" nillable="true" /> 
       <xsd:element name="OutdialPrompt" type="xsd:boolean" minOccurs="0" /> 
       <xsd:element name="NotifyChanges" type="xsd:boolean" minOccurs="0" /> 
       <xsd:element name="NotificationEmail" type="xsd:string" minOccurs="0" nillable="true" /> 
      </xsd:sequence> 
     </xsd:extension> 
     </xsd:complexContent> 
    </xsd:complexType> 
    <xsd:complexType name="ShoretelCosmoMobility"> 
     <xsd:complexContent> 
     <xsd:extension base="t:Configuration"> 
      <xsd:sequence> 
       <xsd:element name="AccountId" type="xsd:int" minOccurs="0" nillable="true" /> 
       <xsd:element name="GroupId" type="xsd:string" minOccurs="0" nillable="true" /> 
      </xsd:sequence> 
     </xsd:extension> 
     </xsd:complexContent> 
    </xsd:complexType> 
</xsd:schema> 

XML :

<?xml version="1.0" encoding="UTF-8"?> 
<ShoretelCosmoConference xmlns="http://www.m5net.com/mantle/configuration/connectors" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> 
    <AccountId>13284</AccountId> 
    <EndConference>Moderator leaves</EndConference> 
    <NotificationEmail /> 
    <NotifyChanges>false</NotifyChanges> 
    <OutdialPrompt>true</OutdialPrompt> 
    <Password /> 
    <StartConference>Host Joins</StartConference> 
    <WebLoginMode>Name Only</WebLoginMode> 
</ShoretelCosmoConference> 

오류 :

XML Validation: Unexpected element(s): 
{http://www.m5net.com/mantle/configuration/connectors}NotifyChanges. Location: 
/*:ShoretelCosmoConference[1]/*:NotifyChanges[1] 
나는 NotificationEmail이 인으로 문제가, 요소의 순서라고 생각
+3

'tns : Configuration'에 XSD 스키마를 제공 할 수 있습니까? 나는 이것이 문제라고 생각한다 – VMAtm

+3

@Raghav 질문에'xsd'와'xml' 코드를 추가하면 문제 문장이 완성됩니다. –

+3

어디서 오류가 있습니까? –

답변

2

귀하의 스키마에서 마지막으로.

<?xml version="1.0" encoding="UTF-8"?> 
<ShoretelCosmoConference xmlns="http://www.m5net.com/mantle/configuration/connectors" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> 
    <AccountId>13284</AccountId> 
    <StartConference>Host Joins</StartConference> 
    <EndConference>Moderator leaves</EndConference> 
    <WebLoginMode>Name Only</WebLoginMode> 
    <Password /> 
    <OutdialPrompt>true</OutdialPrompt> 
    <NotifyChanges>false</NotifyChanges> 
    <NotificationEmail /> 
</ShoretelCosmoConference> 

내가 스키마이 유효성 검사를 사용 : 다음과 같이 데이터 순서를 변경하려고

W3C XML Schema (XSD) Validation online

그리고이 오류가 발생 말한다 :

오류 - 6, 19 번째 줄 : org.xml.sax.SAXParseException; lineNumber : 6; columnNumber : 19; cvc-complex-type.2.4.d : 'NotifyChanges'요소로 시작하는 잘못된 콘텐츠가 발견되었습니다. 이 시점에서 하위 요소는 필요하지 않습니다.

가 나는 XSD 스키마를 재 작성했습니다, 나는 순서 문제한다는 것을 발견 :

<?xml version="1.0" encoding="UTF-8"?> 
<ShoretelCosmoConference xmlns="http://www.m5net.com/mantle/configuration/connectors" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> 
    <AccountId>13284</AccountId> 
    <StartConference>Host Joins</StartConference> 
    <EndConference>Moderator leaves</EndConference> 
    <WebLoginMode>Name Only</WebLoginMode> 
    <Password /> 
    <OutdialPrompt>true</OutdialPrompt> 
    <NotifyChanges>false</NotifyChanges> 
    <NotificationEmail /> 
</ShoretelCosmoConference> 

<?xml version="1.0" encoding="UTF-8"?> 
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.m5net.com/mantle/configuration/connectors" elementFormDefault="qualified" targetNamespace="http://www.m5net.com/mantle/configuration/connectors"> 
    <xs:complexType name="ShoretelCosmoConference"> 
      <xs:sequence> 
       <xs:element minOccurs="0" name="AccountId" nillable="true" type="xs:int" /> 
       <xs:element minOccurs="0" name="StartConference" nillable="true" type="xs:string" /> 
       <xs:element minOccurs="0" name="EndConference" nillable="true" type="xs:string" /> 
       <xs:element minOccurs="0" name="WebLoginMode" nillable="true" type="xs:string" /> 
       <xs:element minOccurs="0" name="Password" nillable="true" type="xs:string" /> 
       <xs:element minOccurs="0" name="OutdialPrompt" type="xs:boolean" /> 
       <xs:element minOccurs="0" name="NotifyChanges" type="xs:boolean" /> 
       <xs:element minOccurs="0" name="NotificationEmail" nillable="true" type="xs:string" /> 
      </xs:sequence> 
    </xs:complexType> 
    <xs:element name="ShoretelCosmoConference" nillable="true" type="tns:ShoretelCosmoConference" /> 
</xs:schema> 

결과 :

는 XML 음입니다 형성되고 유효하다.

+0

일부 블로그에서는 주문이 중요하지 않습니다. 그러나, 시도해보십시오. 오류는 NotifyChanges에 있으며 Not NotificationEmail에는 없습니다. – Raghav

+0

@Raghav 흠, 맞습니다. 순서는 중요하지 않습니다. 코드가'이 아닌''이기 때문일 수 있습니다. – VMAtm

+0

Nopes. 그 중 하나가 작동하지 않았다. – Raghav