2013-09-23 5 views
0

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

Моя схема:

 <?xml version="1.0" encoding="UTF-8"?> 
    <xs:schema 
    xmlns:xs="http://www.w3.org/2001/XMLSchema" 
    xmlns="http://myservices.com/myservices/1.0" 
    targetNamespace="http://myservices.com/myservices/1.0" 
    xmlns:myservices="http://myservices.com/myservices/1.0" 
    xmlns:nc="http://niem.gov/niem/niem-core/2.0" 
    xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" 
    xmlns:i="http://niem.gov/niem/appinfo/2.0" 
    xmlns:s="http://niem.gov/niem/structures/2.0" 
    elementFormDefault="qualified"> 

    <xs:import schemaLocation="niem/niem-core/2.0/niem-core.xsd" namespace="http://niem.gov/niem/niem-core/2.0"/> 

     <xs:element name="MyServices" msdata:Prefix="myservices"> 
     <xs:complexType> 
      <xs:sequence> 
       <xs:element ref="nc:DocumentFileControlID" minOccurs="0" msdata:Ordinal="0" /> 
       <xs:element ref="nc:DocumentCreationDate"/> 
      </xs:sequence> 
     </xs:complexType> 
     </xs:element> 

    </xs:schema> 

И мой XML:

<?xml version="1.0" encoding="UTF-8" ?> 
    <myservices:MyServices xmlns:nc="http://niem.gov/niem/niem-core/2.0" 
     xmlns:niem-xsd="http://niem.gov/niem/proxy/xsd/2.0" xmlns:myservices="http://myservices.com/myservices/1.0" 
     xmlns:s="http://niem.gov/niem/structures/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="MyServices.xsd"> 
     <nc:DocumentFileControlID>20130904-1114.453</nc:DocumentFileControlID> 
     <nc:DocumentCreationDate> 
      <nc:Date>2013-09-04</nc:Date> 
     </nc:DocumentCreationDate> 

    </myservices:MyServices> 

Я получаю ошибку при проверке с использованием SchemaFactory является:

Reason: cvc-complex-type.2.1: Element 'nc:DocumentCreationDate' must have no character or element information item [children], because the type's content type is empty. 

Но в НИЭМ-core.xsd, тип определяется как nc: DateType. Если я попытаюсь добавить этот тип к моему элементу в моей схеме, я получаю сообщение о том, что я не могу иметь тип в элементе.

Это НИЭЙ-core.xsd:

 <?xml version="1.0" encoding="UTF-8"?> 
    <xsd:schema targetNamespace="http://niem.gov/niem/niem-core/2.0" version="1" 
    xmlns:s="http://niem.gov/niem/structures/2.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    xmlns:nc="http://niem.gov/niem/niem-core/2.0" xmlns:niem-xsd="http://niem.gov/niem/proxy/xsd/2.0" 
    xmlns:i="http://niem.gov/niem/appinfo/2.0"> 
     <xsd:annotation> 
     <xsd:appinfo> 
      <i:ConformantIndicator>true</i:ConformantIndicator> 
     </xsd:appinfo> 
     </xsd:annotation> 
     <xsd:import schemaLocation="../../proxy/xsd/2.0/xsd.xsd" namespace="http://niem.gov/niem/proxy/xsd/2.0"/> 
     <xsd:import schemaLocation="../../appinfo/2.0/appinfo.xsd" namespace="http://niem.gov/niem/appinfo/2.0"/> 
     <xsd:import schemaLocation="../../structures/2.0/structures.xsd" namespace="http://niem.gov/niem/structures/2.0"/> 
     <xsd:complexType name="DateType"> 
     <xsd:annotation> 
      <xsd:appinfo> 
      <i:Base i:namespace="http://niem.gov/niem/structures/2.0" i:name="Object"/> 
      </xsd:appinfo> 
     </xsd:annotation> 
     <xsd:complexContent> 
      <xsd:extension base="s:ComplexObjectType"/> 
     </xsd:complexContent> 
     </xsd:complexType> 
     <xsd:element name="DocumentCreationDate" type="nc:DateType"/> 
     <xsd:element name="DocumentFileControlID" type="niem-xsd:string" nillable="true"/> 
    </xsd:schema> 

ответ

0

Есть много ссылок на дополнительные импортируемые XSDs, которые не перечислены в качестве части вопроса. Это делает его трудно быть уверенным, что это неправильно, но одна проблема в том, что xsi:schemaLocation для вашего файла XML должно быть пространством имен URI пары, а не только URI:

xsi:schemaLocation="http://myservices.com/myservices/1.0 MyServices.xsd" 

Если этого не достаточно, чтобы решить вашу проблему , Я бы предложил обрезать xsd:imports вниз, включая любые важные определения типа, такие как ComplexObjectType, в вашем ответе, чтобы у нас был полный набор определений, которые помогут вам решить проблему проверки.

Смежные вопросы