2014-12-29 5 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] 
+3

Можете ли вы предоставить схему XSD для 'tns: Configuration'? Я думаю, что это проблема – VMAtm

+3

@Raghav Пожалуйста, добавьте в свой вопрос код 'xsd' и' xml', поэтому постановка задачи завершена. –

+3

Где ошибка? –

ответ

2

Я думаю, что проблема заключается в порядке элементов, как NotificationEmail является последний в вашей схеме. Попробуйте изменить порядок данных, например:

<?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, а не NotificationEmail – Raghav

+0

@ Raghav Хммм, вы правы, порядок не имеет значения. Может быть, это потому, что ваш код '', а не ''. – VMAtm

+0

Nopes. это тоже не сработало. – Raghav